Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Forum: Fixing WordPress
    In reply to: thumbnail size

    If you have a maximum height and width you’d like, and want WP to ALWAYS make a thumbnail no matter how huge your image is, this code for inline-uploading.php seems to work:

    'FIND THIS LINE:
    add_post_meta($id, '_wp_attachment_metadata', $imagedata);

    /* NOW ADD THIS AFTER IT */
    $maxthumbheight = 450;
    $maxthumbwidth = 450;

    if(($imagedata['width']>$maxthumbwidth) OR ($imagedata['height']>$maxthumbheight)) {

    if($imagedata['width']>$imagedata['height']) {
    $thumb = wp_create_thumbnail($file, $maxthumbwidth);
    } else {
    $thumb = wp_create_thumbnail($file, $maxthumbheight);
    };
    /* DONE ADDING */

    /* COMMENT THIS OUT
    if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
    if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
    $thumb = wp_create_thumbnail($file, 128);
    elseif ( $imagedata['height'] > 96 )
    $thumb = wp_create_thumbnail($file, 96);
    COMMENT THIS OUT */
    if ( @file_exists($thumb) ) {
    $newdata = $imagedata;
    $newdata['thumb'] = basename($thumb);
    update_post_meta($id, '_wp_attachment_metadata', $newdata, $imagedata);
    } else {
    $error = $thumb;
    }
    }

    Basically you can set a maximum thumbnail size for both the height and the width, and it should figure out which of those is the longer edge in your image and constrain it to that. The only time it won’t make a thumbnail is if the image is already smaller than the max thumbnail size itself.

    It still isn’t ideal (it is still hardcoded, but at least it is easier to change than it was before), but for me it seems to have done what I want in the short term… if I had any idea how the WP interface worked I’d try to make up something with some options, but I haven’t develed into that level of things yet.

    Forum: Fixing WordPress
    In reply to: thumbnail size

    I’m really surprised that in an otherwise well-put together piece of code there are such ridiculous things hard-coded into it, like thumbnail size and the rather pointless limitation on what size images it will create thumbnails for… this should be really, really easy to do.

    Thread Starter fastfission

    (@fastfission)

    Here’s a post which discusses the relevant code. I don’t see any great reason that WP hardcodes these values. I’ll try and tinker with them myself… but this seems like a pretty reasonably feature request…

    Thread Starter fastfission

    (@fastfission)

    I’ve tried using Image Manager and it has not been successful at doing this simple thing so far. I will keep playing with it.

    I still think these very simple feature requests could and should be implemented, though, whether there are plug-ins that will hypothetically fix the problem. They have already set up the whole system to use plug-ins, why not make it work well? I am not familiar enough with the WP codebase to want to try and make all the edits myself but I know these are easy fixes in terms of PHP coding, and should not require fancy javascript plugins (which seem to be variously incompatible with different browsers and systems).

Viewing 4 replies - 1 through 4 (of 4 total)