Make WordPress Core

Opened 13 years ago

Closed 11 years ago

Last modified 11 years ago

#15668 closed enhancement (duplicate)

Add additional image sizes to thickbox

Reported by: alexkoti's profile alexkoti Owned by: garyc40's profile 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 13 years ago.
media.2.php (47.1 KB) - added by alexkoti 13 years ago.
image_sizes.gif (29.2 KB) - added by alexkoti 13 years ago.
Additional image sizes listed in insert box.
15668.diff (5.8 KB) - added by garyc40 13 years ago.
based on alexkoti's suggested changes

Download all attachments as: .zip

Change History (18)

@alexkoti
13 years ago

@alexkoti
13 years ago

#1 @nacin
13 years ago

I don't see what this is doing.

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

Please provide a patch.

@alexkoti
13 years ago

Additional image sizes listed in insert box.

#2 @alexkoti
13 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.

#3 @nacin
13 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.

#4 @garyc40
13 years ago

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

@garyc40
13 years ago

based on alexkoti's suggested changes

#5 @garyc40
13 years ago

  • Keywords has-patch added; needs-patch removed

#6 @goto10
13 years ago

  • Cc dromsey@… added

#7 @studiograsshopper
12 years ago

  • Cc studiograsshopper added

#8 @SergeyBiryukov
12 years ago

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

#9 @markoheijnen
11 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.

#10 @SergeyBiryukov
11 years ago

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

Duplicate of #24019.

#11 @SergeyBiryukov
11 years ago

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

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

#12 @SergeyBiryukov
11 years ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened

#13 @SergeyBiryukov
11 years 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.

#14 @SergeyBiryukov
11 years ago

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