WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 23 months ago

Last modified 23 months ago

#15668 closed enhancement (duplicate)

Add additional image sizes to thickbox

Reported by: alexkoti Owned by: garyc40
Milestone: Priority: normal
Severity: minor Version: 3.1
Component: Media Keywords:
Focuses: Cc:

Description

Automatically add additional image sizes to thickbox, and provide a hook to filter sizes, in wp-admin/includes/media.php

function image_size_input_fields( $post, $check = '' ) {

		// get a list of the actual pixel dimensions of each possible intermediate version of this image
		$size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size'));
		
		global $_wp_additional_image_sizes;
		foreach($_wp_additional_image_sizes as $size_name => $size_name_attr){
			$size_names[$size_name] = __($size_name_attr['label']);
		}
		$size_names = apply_filters('image_size_names', $size_names);

		if ( empty($check) )
			$check = get_user_setting('imgsize', 'medium');

Add $label to add_image_size() and set_post_thumbnail_size(), in wp-includes/media.php

/**
 * Registers a new image size
 */
function add_image_size( $name, $width = 0, $height = 0, $crop = FALSE, $label = FALSE ) {
	global $_wp_additional_image_sizes;
	if( empty($label) )
		$label = $name;
	$_wp_additional_image_sizes[$name] = array( 'width' => absint( $width ), 'height' => absint( $height ), 'crop' => !!$crop, 'label' => $label );
}

/**
 * Registers an image size for the post thumbnail
 */
function set_post_thumbnail_size( $width = 0, $height = 0, $crop = FALSE, $label = FALSE ) {
	add_image_size( 'post-thumbnail', $width, $height, $crop, $label );
}

Attachments (4)

media.php (72.7 KB) - added by alexkoti 4 years ago.
media.2.php (47.1 KB) - added by alexkoti 4 years ago.
image_sizes.gif (29.2 KB) - added by alexkoti 4 years ago.
Additional image sizes listed in insert box.
15668.diff (5.8 KB) - added by garyc40 4 years ago.
based on alexkoti's suggested changes

Download all attachments as: .zip

Change History (18)

@alexkoti4 years ago

@alexkoti4 years ago

comment:1 @nacin4 years ago

I don't see what this is doing.

Use case? Example? What's this an enhancement of?

Please provide a patch.

@alexkoti4 years ago

Additional image sizes listed in insert box.

comment:2 @alexkoti4 years ago

The functions I pasted alredy patched. Sorry, I am beginner in Trac tools and I dont know how to post diffs.

I added image showing two extras image sizes, labeled 'Custom Image Size Name' and 'Another Image Size'. The labels are added in two functions of 'wp-includes/media.php'

The hook 'image_size_names' filter these sizes before show in page.

comment:3 @nacin4 years ago

  • Keywords 3.2-early needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Makes perfect sense now, especially after reading this tweet: http://twitter.com/bradleypotter/status/10943590733717504.

Sorry, I must have been tired earlier, because it made no sense then. :)

You can learn how to submit patches at http://core.trac.wordpress.org/#HowToSubmitPatches.

comment:4 @garyc404 years ago

  • Owner set to garyc40
  • Status changed from new to assigned

@garyc404 years ago

based on alexkoti's suggested changes

comment:5 @garyc404 years ago

  • Keywords has-patch added; needs-patch removed

comment:6 @goto104 years ago

  • Cc dromsey@… added

comment:7 @studiograsshopper3 years ago

  • Cc studiograsshopper added

comment:8 @SergeyBiryukov3 years ago

A filter was added in [18802] (for #18520).

comment:9 @markoheijnen2 years ago

  • Keywords needs-patch added; 3.2-early has-patch removed

Since all the changes of 3.5 this patch isn't valid anymore. Not sure if we can close this ticket in favor of #22100.

comment:10 @SergeyBiryukov23 months ago

  • Keywords needs-patch removed
  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from assigned to closed

Duplicate of #24019.

comment:11 @SergeyBiryukov23 months ago

  • Keywords needs-patch added
  • Milestone set to Future Release

Not an exact duplicate, as noted in ticket:24019:2.

comment:12 @SergeyBiryukov23 months ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened

comment:13 @SergeyBiryukov23 months ago

  • Keywords needs-patch removed
  • Milestone Future Release deleted
  • Status changed from reopened to closed

The Thickbox dialog was removed in #21390.

Let's continue with #24168, as it specifically refers to the new media modal.

comment:14 @SergeyBiryukov23 months ago

  • Resolution set to duplicate
Note: See TracTickets for help on using tickets.