Make WordPress Core

Opened 14 years ago

Closed 3 weeks ago

#14106 closed enhancement (wontfix)

Post-processing of post thumbnails

Reported by: nkuttler's profile nkuttler Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Post Thumbnails Keywords:
Focuses: performance Cc:

Description

I'm not sure if I'm missing something, but it looks like there is no hook to post-process post thumbnails. I want to add rounded corners to all thumbnails for a theme.

It looks to me like an action at the end of image_make_intermediate_size() in media.php with $file as parameter might do the trick. I'm not sure if that's the right place or when that function is called precisely though. So it might be necessary to add additional parameters to the function call to identify where the call came from.

Attachments (2)

image_resize_post_process.diff (3.8 KB) - added by nkuttler 13 years ago.
First draft, make post-processing and renaming of thumbnails possible depending on named image_size
demo-plugin.php (351 bytes) - added by nkuttler 13 years ago.
Small demo how the new filters can be used to post-process post thumbnails from a plugin/theme

Download all attachments as: .zip

Change History (17)

#1 @scribu
14 years ago

You know you can make rounded corners on images using CSS, right?

#2 @nacin
14 years ago

  • Keywords close added; post process removed

Yeah, I'd just round them through CSS.

You could also utilize the image_make_intermediate_size filter as a regular action hook if necessary, just make sure you return what you receive.

Works for me?

#3 @nkuttler
14 years ago

  • Cc office@… added

Does image_make_intermediate_size only run once per post thumbnail? I wasn't sure if that's the case. It would also be nice if the filter had some info which thumbnail size is being created, although I guess I could identify the image in the filter. But even then it would not be trivial to have post thumbnails of the same size with different effects.

As for round corners that's just an example. Add graphical borders, apply contrast filters, make black & white, sepia filter, etc.

#4 @nacin
13 years ago

  • Keywords reporter-feedback added; close removed

If the filter doesn't quite work for you, we can add context etc.

#5 @nkuttler
13 years ago

I just had a look at the code again and it looks to me like implementing something like add_image_size( 'frontpage-black-and-white' ) is impossible if a differently named image_size is defined with the same dimensions.

Adding context to the filter would work, but image_make_intermediate_size() currently only receives $file, $width, $height and $crop, not the image_size by name. This could be modified easily I think.

Or maybe additional apply_filters( 'image_make_intermediate_size_$image_size_name', $filter )?

I could work on a patch if this is sounds acceptable.

#6 @nkuttler
13 years ago

I meant

$resized_file = apply_filters('image_make_intermediate_size_$image_size_name', $resized_file);

@nkuttler
13 years ago

First draft, make post-processing and renaming of thumbnails possible depending on named image_size

@nkuttler
13 years ago

Small demo how the new filters can be used to post-process post thumbnails from a plugin/theme

#7 @nkuttler
13 years ago

  • Keywords dev-feedback added; reporter-feedback removed

Messing with the resized image name wasn't really useful, it's better to hook directly into image_resize().

#8 @nkuttler
13 years ago

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

#9 @nkuttler
13 years ago

By the way, my patch would also make it possible to move the default downgrading of thumbnail image quality to a filter that users can remove. Not sure why the quality is reduced to 90.

#11 @nacin
13 years ago

  • Milestone changed from Awaiting Review to Future Release

Looks like a worthy improvement. Let's revisit in 3.2.

#12 @nkuttler
13 years ago

  • Owner nkuttler deleted

#13 @chriscct7
9 years ago

  • Keywords needs-refresh added

Patch needs to be refreshed

#14 @chriscct7
8 years ago

  • Focuses performance added

#15 @pbearne
3 weeks ago

  • Keywords dev-feedback needs-refresh removed
  • Resolution set to wontfix
  • Status changed from assigned to closed

The code has moved on and CSS has moved on so closing this as won't fix

Note: See TracTickets for help on using tickets.