Quantcast
Channel: Thorsten Suckow-Homberg » Hacks
Viewing all articles
Browse latest Browse all 8

ANIga – pimping my gallery

$
0
0

I was looking for a gallery plugin, and among those literally speaking hundreds of gallery extensions for the WordPress blogging software I found ANIga, coded by Michael Naab. Though there are a few unpretty startup errors upon installing and uncatched error-notices during image-processing (Michael, did you forget do set error_reporting to E_ALL?), I’m pleased with the functionality the plugin gives you.

After customizing my default-Template theme I updated the functions.php-file, so that the function “top()” resizes more than 3 images correctly, if you pass any parameter > 3 to the function.

PHP:

  1. function top($numb) {

  2. // print most viewed pictures

  3. /**

  4. * Each picture will be downsized by $spill pixels

  5. */

  6. $spill = round(100/$numb);

  7. global $wpdb, $aniga_lang;

  8. $i = 1; ?>

  9. <div class=“gallery_clear”>

  10. <h2><?php echo $numb; ?> <?php echo $aniga_lang['most_viewed']; ?></h2>

  11. <br />

  12. <?php

  13. $gal_req = “SELECT “.$wpdb->anigal_pic.“.pid, “.$wpdb->anigal_pic.“.path, “.$wpdb->anigal_pic.“.filename, “.$wpdb->anigal_pic.“.hits, “.$wpdb->anigal_alb.“.wp_id FROM $wpdb->anigal_pic, $wpdb->anigal_alb WHERE “.$wpdb->anigal_pic.“.alb_id = “.$wpdb->anigal_alb.“.alb_id “.$this->query(“AND.pic”).” ORDER BY “.$wpdb->anigal_pic.“.hits DESC LIMIT $numb”;

  14. $gal_ret = $wpdb->get_results($gal _req);

  15. if (!empty($gal_ret)){

  16. /**

  17. * modified the computing of the height-attribute for the image.

  18. */

  19. foreach ($gal_ret as $toppic) { ?>

  20. <a href=“<?php echo anigal_get_permalink($toppic->wp_id, $toppic->pid, ‘pid’); ?>” title=“<?php echo $toppic->hits; ?> hits”><img src=“<?php echo $toppic->path . ‘thumb_’ . $toppic->filename; ?>” border=“0″ class=“gallery_pic_border” height=“<?php echo (($numb-($i-1))*$spill); ?>px” align=“bottom” alt=“<?php echo $toppic->hits; ?> hits” /></a>

  21. <?php

  22. $i++;

  23. }

  24. } ?>


Viewing all articles
Browse latest Browse all 8

Trending Articles