WordPress.org

Make WordPress Core

Opened 7 years ago

Last modified 3 months ago

#21714 new enhancement

Enable Intermediate choice in UI if Full Size Image is exact match to Intermediate Image

Reported by: andrewteg Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4.1
Component: Media Keywords: needs-patch
Focuses: administration Cc:
PR Number:

Description

This is simply a minor usability enhancement for Media Gallery. If an image is uploaded that is exactly the same size as an intermediate image (300x300 = Medium for example) it is not a choice when inserting that image into a post. It would be nice if it was a choice pointing to the full/original image since full is the same size as the intermediate.

It seems to be caused in the image_downsize function in /wp-includes/media.php because image_get_intermediate_size returns false.

I believe image_downsize can be updated as such to provide this enhancement:

Line 162 (if statement) Currently:

	if ( !$width && !$height && isset($meta['width'], $meta['height']) ) {
		// any other type: use the real image
		$width = $meta['width'];
		$height = $meta['height'];
	}

could be updated to read the intermediate width and height and set intermediate to true if it is an exact match to the original image:

	if ( !$width && !$height && isset($meta['width'], $meta['height']) ) {
		// any other type: use the real image
		$width = $meta['width'];
		$height = $meta['height'];
		// add check for real image being exact match to intermediate image to enable intermediate choice in UI
		if (isset($_wp_additional_image_sizes[$size])) {
			$goal_width = intval($_wp_additional_image_sizes[$size]['width']);
			$goal_height = intval($_wp_additional_image_sizes[$size]['height']);
		} else {
			$goal_width = get_option($size.'_size_w');
			$goal_height = get_option($size.'_size_h');
		}		
		if ($width == $goal_width && $height == $goal_height)
			$is_intermediate = true;
	}

Thanks for considering, and hope I put this in the right place,
Andrew

Change History (5)

#1 @nacin
6 years ago

  • Component changed from General to Media
  • Milestone changed from Awaiting Review to Future Release

Hi andrewteg, sorry you never received a reply.

Has this been fixed since 3.5's media overhaul?

#2 @andrewteg
6 years ago

Technically it is still there, but I think with the media overhaul it is even more minor an issue, so it's fine to close, but here's the details.

If you add the theme unit's 300x200 it gives you Thumbnail and Full Size, but 300 is the width for "Medium" so it would be nice to have it show as medium even though it would be truly be a pointer to Full Size.

The thought in-house for us was for custom image sizes. It would be easier to tell a user to always select a custom size for a certain usage and if they upload an image of exactly the right width then it would be nice for that custom size to show up for them. Obviously the design and code can take care of poor user choices, but it seemed like a nice fix to give a little more consistency.

#3 @helen
6 years ago

  • Keywords needs-patch added

I agree that it would be nice to fix this and just point to the full size where applicable.

#4 @chriscct7
4 years ago

  • Focuses administration added
  • Severity changed from minor to normal
Note: See TracTickets for help on using tickets.