Support » Plugin: Tag Gallery » [Plugin: Tag Gallery] Temporary Fix to Thumbnail Issue

  • Consider this a reply to this closed thread.

    I was having the same problem of thumbnails not displaying. I also didn’t want to use TimThumb due to the recent security issues and the fact that WordPress has its own built-in image-cropping.

    I made the following changes to tag-gallery.php that fixed the issue and made it use WordPress’s built-in “Thumbnail” size. (Therefore, this fix will break the width and height attributes of the [tag-gallery] shortcode but allow you to manage the thumbnail size on the Settings > Media page.)

    If you make these changes, know that you’re hacking the plugin and the changes will be lost upon upgrading. However, it sounds like a similar fix will be incorporated into the new version anyway.

    The fix(es):

    Change Line 107 to:
    $thumb = wp_get_attachment_image_src( $image['id'], 'thumbnail' );

    Change line 120 to:
    $output .= '<img src="' . $thumb[0] . '" alt="' . $title . '" title="' . $title . '" />';

    Add this line after line 209, inside the foreach loop:
    $images[$key]['id'] = $value['ID'];

    I also chose to delete the tg_generateTimThumbUrl() function and the \timthumb\ folder just for security.

    I really really love the concept of this plugin (particularly when used in conjunction with Media Tags). Seeing that it used TimThumb was disappointing, but it was easy to work around as you can see.

    Thanks for the work @johnnypeck. I look forward to the next version.

Viewing 6 replies - 1 through 6 (of 6 total)
  • @mrwweb – thanks so much for taking the time to post this solution. Really, really appreciated the workaround and thanks to @johnnypeck. Love it.

    No problem @cinemadiving. I take it the fix worked for you?

    Hey thanks for the post most useful however I found I had to add a line to the tag_gallery_get_images() function assigning the value of ID to the images array: $images[$key][‘id’] = $value[‘ID’], see code below for full function.
    Thought I’d post this in case anyone else had the same issue.

    function tag_gallery_get_images($tags) {
    $image_tags = 'media_tags='. $tags;
    $tagged_images = get_attachments_by_media_tags($image_tags);
    if(empty($tagged_images)) return;
    $images = array();
    foreach($tagged_images as $key => $value) {
    	$value = (array) $value;
    	$images[$key] = array();
    	$images[$key]['src'] = $value['guid'];
    	$images[$key]['caption'] = $value['post_excerpt'];
    	$images[$key]['description'] = $value['post_content'];
    	$images[$key]['title'] = $value['post_title'];
    	$images[$key]['id'] = $value['ID'];
    return $images;

    [Moderator Note: Please post code or markup snippets between backticks or use the code button.]

    @kimfya glad you found this useful. Just to make sure people are clear, I think what you suggested is covered in the original instructions I posted:

    Add this line after line 209, inside the foreach loop:
    $images[$key]['id'] = $value['ID'];

    Did you do something in addition to that?

    Do’h your right for some reason in my text editor I was seeing line 109 as 209, not sure why opening it a second time and it all comes together so no you are correct, apologies

    No need to apologize, @kimyfa. I just wanted to make sure that I hadn’t missed something else. (Also, make sure to read the moderator’s note on your last post.)

    Seeing that multiple people have said this fix works, I’m marking this thread as resolved.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: Tag Gallery] Temporary Fix to Thumbnail Issue’ is closed to new replies.