WordPress.org

Ready to get started?Download WordPress

Forums

Change default thumbnail size in WP2.0 (11 posts)

  1. silencematters
    Member
    Posted 7 years ago #

    Hey all -
    There has to be a smart way to change that defaut thumbnail size from 96px x 96px right?

    I know this issue has been brought up before, but nothing has come of it - or maybe the solution has yet to be posted.

    trying to generate some discussion here. Lets help each other out!

  2. jim_m
    Member
    Posted 7 years ago #

    This seems to be hardcoded in the source. If you want to hack it I changed the file wp-admin/inline-uploading.php at line 84 to:


    if ( $imagedata['width'] > 256 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
    $thumb = wp_create_thumbnail($file, 256);
    elseif ( $imagedata['height'] > 192 )
    $thumb = wp_create_thumbnail($file, 192);

    This leaves the thumbnails in the editor upload window small, but when you "send it to editor" they are twice as big. I haven't tested this much, but so far seems to work ok.

  3. silencematters
    Member
    Posted 7 years ago #

    So you changed the thumbsize to less 192px from 96px?

  4. jim_m
    Member
    Posted 7 years ago #

    Yes, the original thumbnails were 128x96 (or 96x128), I just doubled it to 256x192. This seems to work fine for me using firefox.

    However using Internet Exporer I still get small images. Under IE, the code that strips the extra size tags from the image when it gets sent to the editor seems to miss the height tag. (you can see this if you click on the HTML button in the editor, every thumbnail will have a height=128 tag) This seems to stem from the line 426 in


    h = h.replace(new RegExp(' (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)', 'g'), ' $1="$2"$3'); // Enclose
    attribs in quotes

    Which doesn't quote the attributes. Changing it to this:


    h = h.replace(new RegExp('(class|title|width|height|id|onclick|onmousedown)=([^\'"][^ />]*)', 'g'), '$1="$2"');

    Seemed to make it work.

  5. silencematters
    Member
    Posted 7 years ago #

    Hey there Jim
    Thanks for posting back...

    It makes sense how you have changed it to start formatting larger thumbnails.. but I am confused when you start talking about - using Internet Exporer I still get small images. and (you can see this if you click on the HTML button in the editor, every thumbnail will have a height=128 tag).
    I am looking at things in Firefox at the moment, and when I send an image to the editor, I clearly dont see any code that is constraining my image to a paticular size.
    As I understand it, a thumb of the image gets created when you upload, and that thumb image gets called when you send to editor.
    Here is my test page so far.
    http://silencematters.com/growing/
    I dont see from the code how that would be any different in IE. Maybe you are talking about the WP upload manager in IE?

  6. Ryan Fitzer
    Member
    Posted 7 years ago #

    Does anyone have a good idea on how to alter this to simply make all thumbs that are created be the same height (say 150px)?

  7. lcarlos
    Member
    Posted 7 years ago #

    hi jim_m, thank you.
    it helped me.
    i just wanted images width = 240px .
    I changed like you did and it's working fine!
    hugs, from Brazil.

  8. gadlen
    Member
    Posted 7 years ago #

    You can try the Flexible Upload plugin which allows you to resize thumbnails and original images for upload in WP 2.0+ http://blog.japonophile.com/flexible-upload/
    It works quite well :-)

  9. ColourDreamer
    Member
    Posted 7 years ago #

    This didn't work, sigh, but I'm trying the plugin.

  10. pezastic
    Member
    Posted 7 years ago #

    I just installed that plugin and it works like a charm with WP 2.1.2, solving the aforementioned problem. Good job!

  11. sosidge
    Member
    Posted 7 years ago #

    Ditto to the above really, tried the code posted and it didn't seem to make any difference, tried changing a few other mentions of 128 in the code but again it didn't seem to make a difference. I think there must be something deep down in the upload code that makes the thumbnail 128 wide early on, and I decided not to spend hours and hours on it.

    Anyway, downloaded the plugin linked to above and it seems to have done the job, and added a few more options too that I would never have coded myself.

Topic Closed

This topic has been closed to new replies.

About this Topic