Support » Fixing WordPress » Default thumbnail extension changed.

  • Resolved twistedsymphony


    WP 2.5 changed the default file extension for thumbnail images which was *.thumbnail.jpg in WP 2.3 and is now *.HHH-WWW.jpg

    The problem is my site ( uses a plugin (that I wrote) to grab the thumbnail image from the name of the original image.

    It’s now broken for all newly uploaded images because I don’t know what the thumbnail image is.

    Before I could always assume it was .thumbnail.jpb but now I don’t know what it is because it’s .???-150.jpg

    I can modify the wordpress files to “fix” this but I’d rather not because then I have FIX it every time I upgrade. Is there some way I can modify my plugin to know what the thumbnail image from the name of the original file? I needs to work with the 300+ images that I’ve already uploaded with the .thumbnail extension as well as the newly uploaded files.

Viewing 15 replies - 1 through 15 (of 19 total)
  • Can anyone help with this?

    I’d be happy enough with a function that generates the html for the thumbnail and fullsized image link from the file name or post id or something…

    PLEASE ANYONE… I’ve been pulling my hair out over this and it’s essentially holding my site hostage until it’s fixed!

    This is most certainly a hack but I managed to get around this by using the following:

    $attargs = array(
    'post_type' => 'attachment',
    'numberposts' => null,
    'post_status' => null,
    'post_parent' => $post->ID
    $attachments = get_posts($attargs);
    if ($attachments) {
    foreach ($attachments as $attachment) {
    $img_url= wp_get_attachment_thumb_url($attachment->ID);
    $img_url = preg_replace('!(\.[^.]+)?$!', __('.thumbnail') . '$1', $img_url, 1);
    $img_url = wp_get_attachment_thumb_url($attachment->ID);
    $echo .='<a class="itemref" href="'.get_permalink($post->ID).'"><img src="'.$img_url.'" alt="'.apply_filters('the_title', $attachment->post_title).'" /></a>';

    don’t know if that helps, or if there is a better way.

    Where exactly are you using this? It looks like that would echo thumbnails with links for every attachment associated with the current post?

    Not exactly what I’m looking for, but thanks for the response.

    Basically I have a page, and I have meta tag with an image name and sub directory. the image might not even be associated with the current page at all. Then I have some code that looks at the specified image and echos html to display the thumbnail of that image (by simply adding .thumbnail before the extension) as well as makes the image a clickable link to the full sized image.

    I can’t believe there is no function I can use to just say “echo the html to display the thumbnail and a link to the fullsized” How does WP do it when I tell it to insert a thumbnail into my post?

    Over the last three years I’ve submitted maybe a half dozen support questions, all of them dealing with things that aren’t answered in the documentation (I wouldn’t want to waste people’s time with questions I could answer myself) and only ONCE have I received a helpful response and that was for an issue that was up for OVER A YEAR.

    The complete absence of a response from any of the staff makes me feel like a fool for having donated as much as I have to this software team. πŸ™

    The new image uploads don’t add ‘thumbnail’, as you’ve pointed out so I use the above to check for old and new images.

    I use it in my plugin to set a thumbnail per page, or show the first one uploaded via that page.

    hey twistedsymphony,
    had exactly the same problem as you…
    the image_resize function is defined in wp-includes\media.php, line 178, as ibear pointed out here.

    There you should be able to mess with the suffix system as I’m doing right now.

    thanks for the link dardna, I’ve read ibear’s post once before and it’s really a hack… having to modify core wordpress files isn’t really a solution I would like to implement. though it’s looking increasingly that I might have to.

    Thanks elfin.
    I used the checking/comparing/replacing part of your code in a plugin by walter vos called “easygals“, and it allowed me to get his plugin working with WP 2.5

    Thanks! My site is not screwed up anymore πŸ™‚
    (Instead of thumbnails I had the full size images attached which made the site really long.)

    I actually modified that plugin so much that I released it as EasyPermGals, if anyone’s interested.

    This problem with the suffix for images still exists in 2.6. I thought it might have got sorted, but any ideas on what code I need to change in media.php to get this fixed? I’d like to revert to the old way of naming images, e.g. *.thumbnail.jpg

    please help!

    This works for me (but please make a backup of the files before!):

    wp-admin/includes/media.php (about ll. 605)

    $edit_post = sanitize_post($post, 'edit');
    	$file = wp_get_attachment_url($post->ID);
    	$link = get_attachment_link($post->ID);


    $edit_post = sanitize_post($post, 'edit');
    	$file = wp_get_attachment_url($post->ID);
            $medium = ereg_replace(".jpg","-medium.jpg",$file);
    	$link = get_attachment_link($post->ID);

    wp-admin/includes/media.php (about ll. 635)

    <button type='button' class='button url-$post->ID' value=''>" . __('None') . "</button>
    				<button type='button' class='button url-$post->ID' value='" . attribute_escape($file) . "'>" . __('File URL') . "</button>
    				<button type='button' class='button url-$post->ID' value='" . attribute_escape($link) . "'>" . __('Post URL') . "</button>


    <button type='button' class='button url-$post->ID' value=''>" . __('None') . "</button>
    				<button type='button' class='button url-$post->ID' value='" . attribute_escape($file) . "'>" . __('File URL') . "</button>
                                    <button type='button' class='button url-$post->ID' value='" . attribute_escape($medium) . "'>Medium</button>
    				<button type='button' class='button url-$post->ID' value='" . attribute_escape($link) . "'>" . __('Post URL') . "</button>

    wp-includes/media.php (about ll. 224)
    $suffix = "{$dst_w}x{$dst_h}";

    if($max_w == get_option('thumbnail_size_w') || $max_h == get_option('thumbnail_size_h')) { $suffix = "thumb"; }
             elseif($max_w == get_option('medium_size_w') || $max_h == get_option('medium_size_h')) { $suffix = "medium"; }
             else { $suffix = "{$dst_w}x{$dst_h}"; }

    Now you get two thumbnails: a small one (filename-thumb.jpg) and a medium one (filename-medium.jpg). You can change the size in the WordPress config.
    It would be great if anyone could pack that into a plugin.

    Viele Grüße und sorry for my bÀd English!

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Why in the heck are you going to all this trouble? The thumbnail names are stored in the attachment metadata just like the original image name is.

    $meta = wp_get_attachment_metadata( $attachment_post_id );
    echo $meta['thumb'];

    Or heck, even better:
    echo wp_get_attachment_thumb_url( $attachment_post_id );

    Why all the hardship? WordPress has functions to do all this stuff. All you need is the post_id of the attachment.

    All you need is the post_id of the attachment.

    I don’t want to learn the ids of my uploaded pictures by heart πŸ˜‰ . Also you can’t use that function within a post, can you?

    After having uploaded a picture I like to insert the thumbnail with the link to the medium-sized version. Normally wordpress just gives various figures as filename.

    Besides, I worked 30 minutes on that solution, so I’m going to keep it. πŸ™‚

    thanks acrylschaf, I’ll give this a try. appreciate the help. cheers

    thank you Otto42, that was pretty much the solution I was looking for at the beginning but I couldn’t find it documented anywhere and no one seemed to know about it either.

    I’ll look into that and see if I can get it to do what I need it to do πŸ™‚

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Default thumbnail extension changed.’ is closed to new replies.