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";


4 Responses to “Wordpress 2.5 - change the default name extension for thumbnail image”

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

Post a Comment



We use third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you.