Make WordPress Core

Opened 15 years ago

Last modified 6 years ago

#11895 new feature request

Allow more specific image size editing

Reported by: frankgroeneveld's profile frankgroeneveld Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch dev-feedback has-ui-feedback reporter-feedback
Focuses: ui Cc:

Description

Instead of allowing only some combinations of 'thumbnail', 'medium', 'large', 'full' I would like to have the ability to select which of these I would like to crop. So for example, only 'thumbnail' and 'medium'. With the current trunk this is not possible. I created a patch that adds this ability by changing the radio boxes of "apply changes to" in the image-edit page to checkboxes for each of the 4 possible sizes.

Attachments (5)

image-edit.patch (4.5 KB) - added by frankgroeneveld 15 years ago.
Screenshot.png (67.6 KB) - added by frankgroeneveld 15 years ago.
11895.1.diff (6.2 KB) - added by bradt 10 years ago.
Screen Shot 2015-02-22 at 4.38.47 PM.png (962.9 KB) - added by bradt 10 years ago.
11895.diff (6.1 KB) - added by bradt 10 years ago.
Refreshed patch.

Download all attachments as: .zip

Change History (30)

#1 @frankgroeneveld
15 years ago

  • Cc frankgroeneveld@… added

#2 @frankgroeneveld
15 years ago

Note that I modified the image-edit.dev.js, so in order to test this you should regenerate the compressed version (image-edit.js) or symlink to the .dev.js version.

#3 @nacin
15 years ago

  • Keywords image resize editor size thumbnail large medium full removed
  • Milestone set to 3.1

Use of the .dev.js scripts can be enabled by adding define('SCRIPT_DEBUG', true); to wp-config.php.

Media features are being held until 3.1, when the media UI is likely to be overhauled. For what it's worth now just to keep in mind, the patch only accounts for thumbnail/medium/large, but there is an API to specify other sizes as well.

#4 @frankgroeneveld
15 years ago

I didn't even know you could specify more sizes, probably because there is not interface for that. This patch does what I need, so I keep using it until the media overhaul.

Thanks.

#6 @frankgroeneveld
15 years ago

@Denis-de-Bernardy No, that bug adds possible extra sizes, while this patch allows you to have better control over which sizes the "edit image" -> "crop" feature applies to. See screenshot below, my patch replaces the original radioboxes in the right bottom with the checkboxes for all 4 default sizes.

#7 @scribu
15 years ago

  • Keywords has-patch added

#8 @nacin
14 years ago

  • Milestone changed from Awaiting Triage to 3.1

I like this. Late for 3.1 though.

#9 @nacin
14 years ago

  • Milestone changed from 3.1 to Future Release

#10 @goto10
13 years ago

  • Cc dromsey@… added

#11 @frankgroeneveld
13 years ago

This patch still works (altough the javascript offset has moved a little bit).

#12 @SergeyBiryukov
13 years ago

  • Keywords ui-feedback added

#13 @gvenk
13 years ago

  • Cc gvenk added

#14 @bobsoap
12 years ago

  • Cc robert@… added

Is this still being considered for a future release? There seems to be a working patch sitting here since 3 years.

#15 @markoheijnen
12 years ago

Hopefully in version 3.7 but the patch does work but forget custom image sizes. Also the whole editing experience need to change to make it better.

#17 follow-up: @helen
11 years ago

  • Focuses ui added
  • Keywords ui-feedback removed

#18 in reply to: ↑ 17 @mikkelbreum
11 years ago

Replying to helen:
There are some duplicates of this ticket, I guess this is the 'active' one.. I would also love to see this realized in 3.9.x. When editing an image (ie cropping) it should be possible to hand pick the intermediate size(s) that the edit should apply to. It should automatically pick up all registered (custom) image sizes and add those to the apply to options, preferrable as multi choice (checkboxes).

#19 @helen
11 years ago

Related: #27664

Unfortunately, far too late for 3.9.

@bradt
10 years ago

#20 @bradt
10 years ago

  • Keywords dev-feedback ui-feedback added

I've taken a first crack at this.

Because add_image_size() doesn't require labels (like register_post_type() for example), the image_size_names_choose filter is used elsewhere in core to get labels for custom image sizes. For example, the form to insert an image into a post uses it to build a drop down of the available image sizes you can insert into a post. I've used this image_size_names_choose filter here.

Adding your own filter, you can enable your custom image sizes to be in the list. For example, if you had a custom image size named "homepage-thumb", you could add it to the list of checkboxes with the following:

add_filter( 'image_size_names_choose', function( $names ) {
	$names['homepage-thumb'] = __( 'Homepage Thumbnail', 'your-domain' );
	return $names;
} );

Of course, this filter would also make "Homepage Thumbnail" show up in the drop down when inserting an image into a post, which you may not want. So we should probably have our own filter here to define the labels for editing images.

Also, if you don't define a filter for your custom image size, they won't appear in the checkbox list and so won't be editable.

#21 @bradt
10 years ago

Oh, also you may find this handy for testing. Adds a meta box to attachment pages with some nicely formatted attachment meta data.

add_action( 'add_meta_boxes_attachment', function() {
	add_meta_box( 'attach-debug', 'Attachment Debugging', function( $post, $metabox ) {
		echo '<pre>';
		print_r( array(
			'_wp_attached_file' => get_post_meta( $post->ID, '_wp_attached_file', true ),
			'_wp_attachment_metadata' => get_post_meta( $post->ID, '_wp_attachment_metadata', true ),
			'_wp_attachment_backup_sizes' => get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true ),
		) );
		echo '</pre>';
	} );
} );

@bradt
10 years ago

Refreshed patch.

#22 @bradt
10 years ago

Still applies cleanly against trunk. Just checked.

Would be great to get some feedback on this, especially whether the patch should be updated to use its own filter instead of piggybacking on image_size_names_choose.

#23 @bradt
10 years ago

I've just discovered the effort to bring responsive images to WordPress core:
https://wordpress.org/plugins/ricg-responsive-images/

If that plugin is the way forward (which it seems to be), this patch is now a terrible idea. Changes to an image should be applied to all image sizes. The current "Apply changes to:" options should really be removed if that plugin is rolled into core.

I think there is certainly a need for a "treatments" concept that is independent of size though. For example, it's pretty common to want to crop a photo a certain way for display on a listing page (e.g. post archive page) but display the uncropped version on the detail page (e.g. single post page). I'm guessing that was the original intention of the "Apply changes to:" feature, but it never really hit the mark.

This ticket was mentioned in Slack in #feature-imageflow by bradt. View the logs.


10 years ago

#25 @karmatosed
8 years ago

  • Keywords has-ui-feedback reporter-feedback added; ui-feedback removed

With responsive images in core I also feel this probably removes the need for this patch. I'm interested though in feedback from @frankgroeneveld as the original reporter.

Note: See TracTickets for help on using tickets.