Make WordPress Core

Opened 13 years ago

Closed 9 years ago

#19872 closed enhancement (maybelater)

Add Hook/Filter to image_resize_dimensions in media.php

Reported by: webbtj's profile webbtj Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3.1
Component: Media Keywords:
Focuses: Cc:

Description

It would be great if a hook, a filter, a global, an option, or something somewhere were created to allow the image_resize_dimensions() function in media.php to resize images to be larger than the original. In a typical scenario I can understand why you would not want to allow this, however there are rare circumstances where this would be helpful (generating a background image). Currently lines 349 and 350 of media.php read:

$new_w = min($dest_w, $orig_w);
$new_h = min($dest_h, $orig_h);

and lines 378 to 380 read:

// if the resulting image would be the same size or larger we don't want to resize it
if ( $new_w >= $orig_w && $new_h >= $orig_h )
	return false;

It would be great if we were provided a boolean to alter these two blocks, for example:

if($allow_resize){
	$new_w = $dest_w;
	$new_h = $dest_h;
}else{
	$new_w = min($dest_w, $orig_w);
	$new_h = min($dest_h, $orig_h);
}

...

// if the resulting image would be the same size or larger we don't want to resize it
if ( $new_w >= $orig_w && $new_h >= $orig_h && !$allow_resize)
	return false;

Change History (5)

#1 @scribu
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

There already are two hooks in the wp_generate_attachment_metadata() function: 'intermediate_image_sizes_advanced' and 'wp_generate_attachment_metadata'.

They should be enough.

#2 @scribu
13 years ago

  • Component changed from General to Media
  • Keywords 2nd-opinion added
  • Milestone set to Awaiting Review
  • Resolution wontfix deleted
  • Status changed from closed to reopened
  • Type changed from feature request to enhancement

Sorry, you were obviously talking about something else.

#3 @ericlewis
11 years ago

Related / duplicate: #21294

Last edited 11 years ago by ericlewis (previous) (diff)

#4 @wonderboymusic
11 years ago

#21294 was marked as a duplicate.

#5 @chriscct7
9 years ago

  • Keywords 2nd-opinion removed
  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from reopened to closed

There doesn't seem to be much interest in adding these filters. Closing as maybelater.

Note: See TracTickets for help on using tickets.