WordPress.org

Make WordPress Core

Opened 13 years ago

Closed 7 years ago

#8599 closed feature request (duplicate)

Multiple custom image sizes with retroactive image reprocessing

Reported by: markjaquith Owned by: leogermani
Milestone: Priority: normal
Severity: normal Version: 2.8.4
Component: Media Keywords: needs-testing has-patch dev-feedback
Focuses: Cc:

Description

You should be able to add multiple custom image sizes. And whenever you change or add a size, WordPress should offer to retroactively create images of that size for all your old uploads.

Attachments (8)

multiple_custom_image_sizes.patch (26.8 KB) - added by leogermani 12 years ago.
First patch to this ticket
multiple_custom_image_sizes.2.patch (26.4 KB) - added by leogermani 12 years ago.
Second version of the patch. Works when javascript is disabled
multiple_custom_image_sizes.3.patch (34.9 KB) - added by leogermani 12 years ago.
Regenerate thumbnails
multiple_custom_image_sizes.4.patch (38.1 KB) - added by leogermani 12 years ago.
updated to last trunk
multiple_custom_image_sizes_1.png (63.2 KB) - added by leogermani 12 years ago.
Screenshot of the Media option screen with the patch applied
multiple_custom_image_sizes_2.png (63.4 KB) - added by leogermani 12 years ago.
screenshot: adding a new size
multiple_custom_image_sizes_3.png (67.9 KB) - added by leogermani 12 years ago.
screenshot: setting the new size and saving
multiple_custom_image_sizes_4.png (119.1 KB) - added by leogermani 12 years ago.
screenshot: The Patch in action, add a picture screen shows the new size option for insertion

Download all attachments as: .zip

Change History (45)

#2 @ryan
13 years ago

  • Milestone changed from 2.8 to 2.9
  • Type changed from enhancement to feature request

#3 @ryan
13 years ago

  • Priority changed from high to normal

#4 @Denis-de-Bernardy
12 years ago

  • Keywords needs-patch added

#5 @leogermani
12 years ago

  • Owner set to leogermani
  • Status changed from new to reviewing

#6 @leogermani
12 years ago

  • Keywords 2nd-opinion needs-testing added; needs-patch removed
  • Version changed from 2.7 to 2.8.4

#7 @leogermani
12 years ago

  • Keywords has-patch added

In this first patch I implement the posibility to add new custom image sizes to WordPress.

  • It was made upon the patch submited on ticket: #10263 (my patch replaces this one)
  • It does not "retroactively create images of that size for all your old uploads" yet.
  • Ive put some css styles in the elements cause I was not sure where to put them (and there were really few of them)

@leogermani
12 years ago

First patch to this ticket

@leogermani
12 years ago

Second version of the patch. Works when javascript is disabled

#8 @leogermani
12 years ago

  • Keywords dev-feedback added

#9 @scribu
12 years ago

Looks good.

It solves the first half of the problem. :)

#10 @leogermani
12 years ago

  • Cc leogermani added

Good,

I can implement the second half, but I wanted more opinions on how it should work. I dont think it is a good idea to make it regenerate all images automatically on every change, because it is too heavy. Here are the approaches I am considering:

  1. Have a button "Regenerate images" where the user clicks whenever he wants to regenerate all images thumbs
  1. Whenever you change the values of a size, a box appears at the top of the screen informing that the changes do not apply to old images, but if (s)he wants to regenerate, 'click here'

In both cases I am thinking to do this trhough ajax so user have a constant feedback on each file beeing processed and is able to cancel the routine.

Opinions?

Leo

#11 @scribu
12 years ago

I think the second option would make more sense.

You have to use some combination of AJAX and possibly wp-cron to prevent timeouts and other limits.

Plugins that use this approach: Intense Debate, WP DB Backup.

Maybe you can work with Viper007Bond to improve the Regenerate Thumbnails plugin and then consider including it in core.

#12 follow-up: @leogermani
12 years ago

The thing with the second option is that if the user dont click on the regenerate button as soon as he changes the values, he misses the chance and have to change the values again if he wants to reprocess the images. Perhaps leaving the 2 actions can be good.

Now one question. If we decide on an ajax approach. How would it work whithout javascript? Do you think it could be a JS-enabled-only feature?

#13 in reply to: ↑ 12 @scribu
12 years ago

Replying to leogermani:

The thing with the second option is that if the user dont click on the regenerate button as soon as he changes the values, he misses the chance and have to change the values again if he wants to reprocess the images. Perhaps leaving the 2 actions can be good.

Agree.

Now one question. If we decide on an ajax approach. How would it work whithout javascript? Do you think it could be a JS-enabled-only feature?

Actually, the AJAX would only be used to update the status without refreshing the page. The crunching would be done in the background anyway. Withot JS, the user would just see a static notice: "Regenerating images: 25% done." or something like that.

#14 @scribu
12 years ago

  • Keywords 2nd-opinion removed

A plugin that regenerates the thumbs through AJAX has sprung up:

AJAX Thumbnail Rebuild

#15 @leogermani
12 years ago

New patch (3). Retroactive image reprocessing

Added the regenerate all thumbnails funcionality

  1. I did without ajax (at least for the moment). When I finished it I didnt see so much the need for an ajax alternative
  1. I created a function called wp_update_thumbs - I though it was worth to have it so we can use in other places in the code, such as in the manage media page, I think there could be there a button to regenerate the thumbs for each image. It could be a button for each image and a bulk action
  1. It patches the new "Edit Image" feature too

@leogermani
12 years ago

Regenerate thumbnails

#16 @scribu
12 years ago

Patch needs refresh (patch rev: 11953, trunk rev: 12055)

Although I would really like this patch commited, 2.9 is already in feature freeze.

@leogermani
12 years ago

updated to last trunk

#17 follow-up: @markjaquith
12 years ago

I think it's too late for this for 2.9. I have another way I'd like to do it that doesn't involve laborious "rebuilding." I'd like WP's image attachment HTML output functions to check for the existence of a file in a specified size and build it on the fly if it doesn't exist.

#18 in reply to: ↑ 17 ; follow-ups: @scribu
12 years ago

Replying to markjaquith:

I think it's too late for this for 2.9. I have another way I'd like to do it that doesn't involve laborious "rebuilding." I'd like WP's image attachment HTML output functions to check for the existence of a file in a specified size and build it on the fly if it doesn't exist.

Sort of like TimThumb, right? The only issue would be: how do you get rid of files that aren't used anymore?

#19 in reply to: ↑ 18 @scribu
12 years ago

Replying to scribu:

The only issue would be: how do you get rid of files that aren't used anymore?

Right, a wp-cron job that regularly scans files using fileatime() will do.

#20 @ryan
12 years ago

  • Milestone changed from 2.9 to 3.0

#21 @westi
12 years ago

Discussed on Oct 22nd dev chat. Summary:

  • Good idea to improve this area of WordPress
  • Not sure about exact details or the reprocessing
  • Need to discuss some more exactly what we want here.

#22 in reply to: ↑ 18 ; follow-up: @miqrogroove
12 years ago

Replying to scribu:

how do you get rid of files that aren't used anymore?

Maybe a better question is why are thumbnails generated even when they are not used?

#23 in reply to: ↑ 22 @Viper007Bond
12 years ago

Replying to miqrogroove:

Replying to scribu:

how do you get rid of files that aren't used anymore?

Maybe a better question is why are thumbnails generated even when they are not used?

Because it's slow, complicated, and generally bad to generate them on the fly unless you have a good server.

#24 @miqrogroove
12 years ago

  • Cc miqrogroove@… added

I keep forgetting the Media Gallery uses the small thumbnails. Anyway, I see there hasn't been agreement on whether or not to regenerate custom sizes on the fly. Let me just add that when I was working on the thumbnail system for XMB, we determined mass thumbnail regeneration was too CPU intensive to be viable in most environments. At that point we abandoned the idea as being counterproductive.

#25 follow-up: @leogermani
12 years ago

Just to tell that I didnt give up on that.... I want to wait 2.9 release and then update the patch to the last trunk. I dont like the idea of the regenerating proccess beeing in the core too, so I will remove it.

I would really like more people to comment on that... I think this is a very good feature to go into 3.0

Leo

#26 in reply to: ↑ 25 ; follow-up: @miqrogroove
12 years ago

Replying to leogermani:

I would really like more people to comment on that... I think this is a very good feature to go into 3.0

IMHO, being able to specify the image size in the post editor is the most needed feature. If I upload a 2000 x 2000 image, I'm given only the options defined in image settings. Regardless of how many choices are available, I might want something different. Currently it uses HTML attribute sizing, which is useless to an experienced web author. I'm not sure if that's on-topic though. The feature described by this ticket has more to do with thumbnails for theme changes?

@leogermani
12 years ago

Screenshot of the Media option screen with the patch applied

@leogermani
12 years ago

screenshot: adding a new size

@leogermani
12 years ago

screenshot: setting the new size and saving

@leogermani
12 years ago

screenshot: The Patch in action, add a picture screen shows the new size option for insertion

#27 in reply to: ↑ 26 @leogermani
12 years ago

Replying to miqrogroove:

The feature described by this ticket has more to do with thumbnails for theme changes?

Ive attached some screenshots to this ticket to make it easier to understand what this patch is all about.

It allows you to create many custom sizes. When you upload a picture, WP will generate copies of this image in all sizes you configured (if possible).

When you add a picture to a post, you will have the option to insert your sizes.

This patch also fixes ticket #10263

It is not updated to the latest trunk. I nedd to know if its going into 3.0 or not, so I can update the patch

#28 @ShaneF
12 years ago

  • Cc ShaneF added
  • Component changed from Upload to Media
  • Milestone changed from 3.0 to Future Release

All 'media' based new features are on hold and pushed to 3.1.x. Because of the SOW set for 3.0 this does not fall into that category.

#29 @markjaquith
12 years ago

  • Milestone changed from Future Release to 3.1

#31 @scribu
12 years ago

A plugin for custom image sizes:

Additional image sizes

#32 @nacin
11 years ago

  • Milestone changed from Awaiting Triage to Future Release

#33 @gruvii
10 years ago

  • Cc gruvii added

#34 @husobj
9 years ago

  • Cc ben@… added

This ticket was mentioned in Slack in #core by eric. View the logs.


7 years ago

This ticket was mentioned in Slack in #core by eric. View the logs.


7 years ago

#37 @nacin
7 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from reviewing to closed

Closing this as a duplicate of #15311 which is a more complete body of research and pool of ideas.

Note: See TracTickets for help on using tickets.