WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 3 months ago

#32313 reopened enhancement

Image upscale as Media's settings option

Reported by: odie2 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.3
Component: Media Keywords: bulk-reopened
Focuses: administration Cc:

Description

Hello,

I had to searching for hours to find image upscale (because unusually keyword for me as non-English). I am creating new school's website and custom featured images are up to 1200px width (in fact ~876px when with sidebar), however old images are only 800px width and I had problem with deal it.

I found so simple solution to set image to required width/height if not enought, then crop.

/*  Thumbnail upscale
/* ------------------------------------ */ 
function alx_thumbnail_upscale( $default, $orig_w, $orig_h, $new_w, $new_h, $crop ){
    if ( !$crop ) return null; // let the wordpress default function handle this
 
    $aspect_ratio = $orig_w / $orig_h;
    $size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
 
    $crop_w = round($new_w / $size_ratio);
    $crop_h = round($new_h / $size_ratio);
 
    $s_x = floor( ($orig_w - $crop_w) / 2 );
    $s_y = floor( ($orig_h - $crop_h) / 2 );
 
    return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
}
add_filter( 'image_resize_dimensions', 'alx_thumbnail_upscale', 10, 6 );

​http://alxmedia.se/code/2013/10/thumbnail-upscale-correct-crop-in-wordpress/

In my opinion it should be included as option for each/globally for image sizes in Media's settings page and also as fifth parameter for add_image_size(), because this can make big headache.

Greetings

Change History (4)

#2 @acha5066
4 years ago

I can see why people don't want images to be upscaled as it would make the image fuzzy. However, I'm currently doing a rebuild of an old site in which the container size has increased in width. As a result some of their images (there are 1600) look odd in the layout. If you wanted for example images to be of the same height, so it looked balanced in a two column layout and you had an old image that was larger enough to be resized but one that was too small and therefore wasn't, the layout would look odd.

Some images are only a little bit too small and a tiny bit of stretching is not too bad, when the alternative is manually resizing all images. I think adding this as a parameter to add_image_size would be a good idea. Those who don't want them upscaled can choose not too (it could be the default) and those who do can opt in.

#3 @iseulde
4 months ago

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

This ticket has not seen any activity in over *two* years, so I'm closing it as "wontfix".

The ticket may lack decisiveness, may have become irrelevant, or may not have gathered enough interest.

If you think this ticket does deserve some attention again, feel free to reopen.

For bugs, it would be great if you could provide updated steps to reproduce against the latest version of WordPress (5.0.2 at the time of writing). Remember images or a video can be superior to explain a problem. At the very least, quickly test again to make sure the bug still exists.

If it’s an enhancement or feature, some extra motivation may help.

Thank you for your contributions to WordPress! <3

#4 @JeffPaul
3 months ago

  • Keywords bulk-reopened added
  • Milestone set to Awaiting Review
  • Resolution wontfix deleted
  • Status changed from closed to reopened

A ​decision was made to reopen tickets that were closed in the bulk edit that this ticket was affected by. This ticket is being placed back into the Awaiting Review milestone so it can be individually evaluated and verified to determine if it is still relevant/valid or reproducible.

Note: See TracTickets for help on using tickets.