• Hi guys, I’ve been mightily confused by the thumbnail features of WordPress.

    So, when I upload a new image, it is being automatically cropped to a number of sizes, e.g. 75×75, 100×100, 150×150, width 300, width 450, etc. This happens at upload. Now, the square ones above apply cropping from the center. This is not always the best crop – and searching on the topic shows many have similar issues.

    So when I edit an image in Media Library, it allows be to crop. The image editor is a bit tricky to work with, but can be figured out. So I manage to do a crop, save it and press update image. However, all that happens is:
    1) One new image is created in the uploads directory, named (imagename)-e1311232…-150×150.png.
    2) The new crop is showed for the Media Library thumbnails, but nowhere else!

    So, what confuses me is:
    1) The new crop only applies to 150×150
    2) The original image is not updated (which would have propagated the crop to all existing uses of the thumbnail!)
    3) Only the media library shows the new thumbnail – it is not shown when inserting in a new post.

    Using this function, I would rather assume that the custom crop that is applied is given to all thumbnail sizes that would normally be done, and that the original thumbnails are being updated so that I don’t need to link manually to the new crop.

    Is this intended functionality, a bug or is there a plugin that can sort it out? I have tried Regenerate Thumbnails, but that basically just re-creates the thumbnails in the original crop, ignoring my custom setting.

Viewing 2 replies - 1 through 2 (of 2 total)
  • i’ve the same problem as you .. i’m going to be crazy. Did you manage to solve it?

    Thread Starter ripperdoc

    (@ripperdoc)

    Hi, I did a hack that solves the most urgent issue. The problem is that images changed by media library editor gets new filenames – any old references to the thumbnail will therefore point to the unedited version. This hack will rename the edited image to the original (overwriting it!). Only affects intermediate size, e.g. 150×150 thumbnails, at the moment.

    /**
     * Edited images using media library image editor gets new filenames, so
     * will not automatically be used by posts where they have already been inserted.
     * This filter detects those re-crops and changes the name back to the original
     * Caution: Will overwrite original thumbnail. Only affects "intermediate size".
     * By ripperdoc.net
     */
    function overwrite_recropped_thumbnail($resized_file) {
    	// Remove timestamp added to re-cropped images. TODO improve regex to avoid
    	// accidental path changes
    	$new_path = preg_replace( '/-e([0-9]+)-/', '-', $resized_file, -1, $count );
    	if($count>0) { // The file path had the timestamp, move back to original name
    		rename($resized_file, $new_path);
    		return $new_path;
    	} else { // do nothing
    		return $resized_file;
    	}
    }
    add_filter('image_make_intermediate_size', 'overwrite_recropped_thumbnail',10);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Cropping images and thumbnails in Media Library editor’ is closed to new replies.