By klcthebookworm on
I'm running Drupal 4.7, and installed this PHPsnippet from http://drupal.org/node/53987 in a block:
$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++; }
It's working, but displaying random images from the total group of images. Right now I have "Image Galleries" set up as a category, with each artist getting a separate term under that. One term is an admin's choice and that's the only group of images I want this coding to pull from. I put the name of that term where the code says to "enter the name of the gallery here" but it pulls from all the images.
I don't know PHP and could really use the help.
Comments
my solution
You do not need a custom block to do this with the latest image module, you can do this by customising the module itself. if you check out your image.module at line 402 you will see that it's possible to select a specific term to create the random image from.
the only thing you have to do is to change the term id $tid at line 402 in your image.module file into the number under which you have your gallery of choice. For example if you would be using the gallery under the term with the number 3 this codeline would become:
-----------------
Check out our blog on http://www.pronovix.com/blog
That works but...
Thanks it's now only using the picks from the gallery I wanted to. :)
But where's the line to change the title of the block from "Random Image"?
And no, it's not available for changing under Administrative > blocks in bluemarine theme. So where is the name of the block hiding?
to change the title of the block from "Random Image"
edit image.module, line 223:
$block['subject'] = t('Random image');THANKS! Now the title is
THANKS! Now the title is right!
http://www.altbikermice.us/