[support] tweaking php to get random images from multiple galleries
will hall
will at theicarusproject.net
Wed Aug 22 12:48:00 UTC 2007
hi all, this is from the -> PHP snippets section of the drupal website:
Customization and theming » PHP snippets » PHP block snippets
Random image from a particular category/gallery
can someone help tweak this so you can have it grab the images from
several diferent galleries, rather than just one?
i'm very new to php, but i don't think adding several gallery names,
separated by commas, will work...
thanks!
-- will
<?php
$gallery_name='Enter the name of the gallery
here';
$term = taxonomy_get_term_by_name($gallery_name);
$tid = $term[0]->tid;
$thumbs = 0;
while ($thumbs<1) {
$images = (image_get_random($count = 1, $tid));
print l(image_display($images[0],
'thumbnail'),'node/'.$images[0]->nid, array(),
null, null, FALSE, TRUE);
$thumbs++;
}
?>
More information about the support
mailing list