WordPress.org

Forums

All Thumbnails Of Uploaded Images Cropped Automatically (4 posts)

  1. BTF2
    Member
    Posted 6 years ago #

    Of late I have noticed that all thumbnails of images I upload via the Flash uploader or the browser method are cropped square. Clicking on the thumbnail takes you to the properly proportioned image, but it can still make for some odd-looking posts where the thumbnails have important information cropped out!

    Looking back through my posts I note that this hasn't always been the case and looks like it might have crept in around 2.5.x (I am using 2.6.1).

    A quick search through the forums found a similar post, but there were no replies, hence the new one.

    So, to summarise, how do I revert to thumbnails that are miniature versions of the original rather than square and/or cropped?

    Cheers,

    BTF2

  2. simonelli
    Member
    Posted 6 years ago #

    Yes, I'm having this problem too. I hope we gert an answer soon.

  3. mtg169
    Member
    Posted 6 years ago #

    I just started getting this problem in 2.7.1. Also use thumbnail for excerpts plugin. It's been working fine for awhile, but now all thumbnails are being cropped. The Media settings option "Crop thumbnail to exact dimensions (normally thumbnails are proportional)" is disabled, so I'm not sure why the thumbnails are being cropped still.

  4. mtg169
    Member
    Posted 6 years ago #

    I ended up just commenting all of the following code in wp-includes/media.php

    if ( $crop ) {
    		// crop the largest possible portion of the original image that we can size to $dest_w x $dest_h
    		$aspect_ratio = $orig_w / $orig_h;
    		$new_w = min($dest_w, $orig_w);
    		$new_h = min($dest_h, $orig_h);
    		if (!$new_w) {
    			$new_w = intval($new_h * $aspect_ratio);
    		}
    		if (!$new_h) {
    			$new_h = intval($new_w / $aspect_ratio);
    		}
    
    		$size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
    
    		$crop_w = ceil($new_w / $size_ratio);
    		$crop_h = ceil($new_h / $size_ratio);
    
    		$s_x = floor(($orig_w - $crop_w)/2);
    		$s_y = floor(($orig_h - $crop_h)/2);
    	}

    I am still unsure why the images are being cropped because the setting to crop them is unchecked. The image_resize_dimensions is also passing $crop=false. Ideally I'd like to find an actual fix so media.php doesn't have to be hacked.

Topic Closed

This topic has been closed to new replies.

About this Topic