Home > Blogs, Bookmarks, PhP, Tech, Wordpress > Wordpress 2.5 – change the default name extension for thumbnail image

Wordpress 2.5 – change the default name extension for thumbnail image

The thumbnail images generated by old wordpress, usually ended with ***.thumbnail.jpg, but now with upgraded to 2.5, it’s ***-150×150.jpg. Where 150×150 is the default width x height (wp admin).

How can you change back to the original format (.thumbnail.jpg)?

The method handling the creation of thumbnail images are in file wp-includes\media.php. Code handling filename (for WP. 2.5.1) are line 206, 214 and line 226:

$suffix = "{$dst_w}x{$dst_h}";
line 206 change with:
$suffix = "thumbnail";

,

$destfilename = "{$dir}/{$name}-{$suffix}.{$ext}";
line 214 become:
$destfilename = "{$dir}/{$name}.{$suffix}.{$ext}";

and

$destfilename = "{$dir}/{$name}-{$suffix}.jpg";
line 226:
$destfilename = "{$dir}/{$name}.{$suffix}.jpg";

  1. February 14th, 2009 at 15:08 | #1

    here is the solution:
    replace this:
    $aImgName = explode(’.',$strSrcImgName);
    with this:
    $aImgName = substr($strSrcImgName,0,strrpos($strSrcImgName, "."));

    woking with 100+ dots :D …. have fun!

  2. Matteo
    February 14th, 2009 at 11:41 | #2

    I created this workaround to solve the problem. Basically I use the WP function “image_resize_dimensions” which calculates the dimensions of a resized image, according to Settings->Media numbers.

    My workaround is supposed to be used with images that contain no dots (except the one for the extension: i.e. my.picture.jpg doesn’t work, while my-picture.jpg works)

    Finally…here is the code:

    //Gets the custom field of the post
    $strSrcImgName = get_post_meta($post->ID, ‘img_main’,1);

    //Gets dims of the original image
    list($orig_w, $orig_h) = getimagesize( $_SERVER["DOCUMENT_ROOT"].get_option(’upload_path’).’/’.$strSrcImgName );

    //Calculates dims of the “medium size” resized image
    list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = image_resize_dimensions($orig_w, $orig_h, get_option(’medium_size_w’), get_option(’medium_size_h’), false);

    //..here it is why it doesn’t work with images with more than one dot
    $aImgName = explode(’.',$strSrcImgName);
    $strMediumImgName = $aImgName[0].’-’.$dst_w.’x’.$dst_h.’.’.$aImgName[1];

  3. Matteo
    January 30th, 2009 at 17:58 | #3

    Thank you for this suggest.

    I changed the script as you wrote, but now WP generates just 2 images (insted of 4): myimage.jpg (original size) and myimage.thumbnail.jpg (dimensions as specified in Settings > Media > “Big size image” …or something similar, sorry, I’m working with an italian versione :) ).

    So I lost two image: “Middle size” and “Thumbnail” (the one I can choose to crop).
    Is there a solution to this?
    I’m using WP 2.7

    Thanks in advance.

  4. Raphael
    January 29th, 2009 at 18:21 | #4

    Thank you for this phantastic hint! It took me 3 hours to find our why the thumbs have other names now! Sometimes I have the impression, that WP just wants to make uns mad!
    Greetings!
    Raphael

  1. No trackbacks yet.
GoCache - ByREV-Cache v1.0 - live served in : 0.155909 sec (gzip)