Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If only a single image is uploaded, can Imagefield Cycle automatically hide the little pager image?
Otherwise, I'm going to have to make a 2nd field that is only to be used if there is one image. Or am I missing something?
Comment | File | Size | Author |
---|---|---|---|
#8 | 1138318_handle_single_image.patch | 1.27 KB | greggles |
#6 | Screen shot 2011-06-14 at 14.04.46.png | 195.85 KB | lisarex |
Comments
Comment #1
nicholasThompsonThat would be a very good/sensible option to have. Currently I believe it'll just have a single image in the "pager" section.
Comment #2
lisarex CreditAttribution: lisarex commentedWe would be happy to create a patch for this, if you'd accept it. We definitely need this to work for single images.
Comment #3
lisarex CreditAttribution: lisarex commentedClarification: I can confirm it's definitely showing a pager even with a single image. I do want one field to handle all images. Imagefield Cycle works great for multiple images, but occasionally there will only be a single image on a node.
Comment #4
amateescu CreditAttribution: amateescu commented@lisarex: do you think that this should be a configurable option? Something like.. "Hide pager if it contains a single item" that will be checked by default.
Comment #5
lisarex CreditAttribution: lisarex commentedAmateescu, I can't think of an instance where a single image + pager would be desirable. So I would just say that if there's a single image, the 'pager thumbnail' is hidden.
Comment #6
lisarex CreditAttribution: lisarex commentedAttached is what the single image + thumbnail looks like. If someone can do a patch that removes thumbnail pager for single images, I'll do a review, since it would be loooovely to have for a client site.
Comment #7
bhavin.ahya CreditAttribution: bhavin.ahya commentedfound the solution
I have overridden following theme function to solve this.
Write down the following function in your template.php
function phptemplate_imagefield_cycle_image($image_data, $element, $profile, $key) {
// This just keeps the code neater below
$i = &$image_data;
if ($i['path'] != '') {
return theme('imagecache', $i['presetname'], $i['path'], $i['alt'], $i['title'], $i['attributes'], $i['getsize']);
}
}
Write down the following code in your any .js file
var getthumbimg = $('.thumb-images .thumb-image-item');
if ($(getthumbimg).children('img').length == 1) {
$('.thumb-images').css('display','none');
};
Just clear the cache and refresh the node view page.
let me know if issue still persists.
Comment #8
gregglesHere is that code as a patch to the module.
If it's right, it can be committed with --author="bhavin.ahya " to give credit to bhavin.ahya.
Comment #9
bhavin.ahya CreditAttribution: bhavin.ahya commentedThanks greggles.
I have implemented the same and it's working fine.
Comment #10
nicholasThompsonI have committed this to dev. Unfortunately, the "author" parameter caused the following error:
fatal: No existing author found with 'bhavin.ahya'
...This fix is good enough for an initial fix. It'd be nice to not have the thumbnail rendered at all if the image count == 1...
Comment #11
gregglesdang, the html filter stripped the important parts. You can find the author attribution information on user profiles (like http://drupal.org/user/379122) in the future.
Thanks, nicholas!
Comment #12
nicholasThompsonAhhh right :) I did not know that! I'm still learning Git... more of an SVN man myself ;)