Opened 17 years ago
Closed 16 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: |
Description
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)
Change History (8)
#1
@
17 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.
#3
@
17 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
@
17 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.
diff between 2.1 trunk and my proposal