Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#3605 closed enhancement (invalid)

Proposal fine-tuned thumbnail creation function

Reported by: BjornW Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.1
Component: Administration Keywords: wp_create_thumbnail, thumbnail, core, proposal
Focuses: Cc:


This is a quick proposal for a more fine-tuned way of creating thumbnails. It would need some more work to make it work out of the box, but I wanted to get some feedback before spending more time on this.

As far as I understoord the wp_create_thumbnail function (located wp-admin/admin-functions.php) is looking at $maxside in determining the maximum side. Be it the width or the height. My proposal allows you to select the maximum side explicitly which eventually could help theme authors in maintaining a more consistent look due to the images having either the same width or height.

Besides this I also changed the error handling in such a way that any error created will result in a returned error message (type array). The error messages also have been made a bit more descriptive. E.g. jpg thumbnail could not be created, instead of:

Filetype not supported. Thumbnail not created.

I changed it to:

Filetype: jpg not supported. Thumbnail not created.

Looking forward to hear some feedback!

Attachments (1)

wp_thumbnail_create.diff (6.8 KB) - added by BjornW 11 years ago.
diff between 2.1 trunk and my proposal

Download all attachments as: .zip

Change History (8)

11 years ago

diff between 2.1 trunk and my proposal

#1 @mdawaffe
11 years ago

The changes made at #3588 ([4751] and [4759]) make the thumbnail size fully pluggable by filtering inside wp_generate_attachment_metadata(). Just before a thumbnail is made, a plugin could check the image's aspect ratio and decide what $maxside value to pass on to wp_create_thumbnail().

It's not the cleanest solution, but it's backward compatible. For some future release of WP, we may want to audit the image manipulation functions WP provides and see what the easiest way to use them really is.

So I think your changes to wp_create_thumbnail() are interesting but not strictly necessary now that wp_generate_attachment_metadata() is pluggable.

Also, for error reporting, check out the nice WP_Error class and is_wp_error() that were introduced... I don't know... not so long ago. All error reporting should eventually be switched over to use those.

#2 @BjornW
11 years ago

Allright, I'll have a look at the error handling and see what I can do.

#3 @ryan
11 years ago

  • Milestone changed from 2.1 to 2.2
  • Summary changed from Proposal fine-tuned function to Proposal fine-tuned thumbnail creation function

#4 @robertaccettura
11 years ago

This would be great.

Would be even better if it used script.aculo.us and had that drag/drop crop/resize that digg had (still has?) for it's aviator. Preset to a defined value (an option set by the user).

For example, I like my images at 400px. But sometimes it's better to crop than to just thumbnail it (becomes unreadable, etc). If it did both, it would pretty much eliminate the need for GIMP/Paint.NET/Photoshop.

#5 @foolswisdom
11 years ago

  • Milestone changed from 2.2 to 2.3

#6 @foolswisdom
11 years ago

  • Milestone changed from 2.3 to 2.5 (future)

#7 @pishmishy
10 years ago

  • Milestone 2.6 deleted
  • Resolution set to invalid
  • Status changed from new to closed

Closing as invalid. I believe mdawaffe has answered all the concerns in this ticket.

Note: See TracTickets for help on using tickets.