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?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nicholasThompson’s picture

That would be a very good/sensible option to have. Currently I believe it'll just have a single image in the "pager" section.

lisarex’s picture

We would be happy to create a patch for this, if you'd accept it. We definitely need this to work for single images.

lisarex’s picture

Clarification: 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.

amateescu’s picture

Component: Documentation » Code

@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.

lisarex’s picture

Amateescu, 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.

lisarex’s picture

Attached 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.

bhavin.ahya’s picture

Version: 6.x-1.x-dev » 6.x-1.1
Status: Active » Closed (fixed)

found 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.

greggles’s picture

Status: Closed (fixed) » Needs review
FileSize
1.27 KB

Here 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.

bhavin.ahya’s picture

Thanks greggles.
I have implemented the same and it's working fine.

nicholasThompson’s picture

Status: Needs review » Fixed

I 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...

greggles’s picture

dang, 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!

nicholasThompson’s picture

Ahhh right :) I did not know that! I'm still learning Git... more of an SVN man myself ;)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.