WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 4 months ago

#34223 new feature request

Core support for image regeneration

Reported by: krogsgard Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3
Component: Media Keywords:
Focuses: ui Cc:

Description

Making this a separate ticket from #34196 so as to not hijack another conversation.

I’d like to discuss WordPress doing image regeneration as a part of core.

Images are most often defined in themes, and when switching themes, I think it makes sense to at least offer the ability to easily regenerate images to create the images a theme expects to exist.

Similarly, if the default image sizes are changed, it’d be nice if users could regenerate images to make older images compatible to new size definitions.

I think the nomenclature for images (i.e.: medium, large) help define images well enough that regenerating an image that exists on an old post would not alter it in a way that is out of expectation.

And if we have a new image size that’s equivalent to the content width (and I’d actually argue to make that the standard insert size), it would make sense to be able to change it easily, with core, as part of a theme switch routine.

Change History (6)

#1 @kraftbj
4 years ago

Pitfalls of Viper007's Regen Thumbnails plugin (I think the most popular way to do this currently). Image regen is a stressful process for a server. His plugin requires the browser window open as it reloads the page to continue along the path to prevent PHP timeouts.

In regenerating thumbnails on sites with a ~10 GB of original images, it can take a very long amount of time on a typical shared hosting environment.

Any solution would need to be able to happen in the background, be hard enough to trigger to not kill a server—possibly having some type of record of what images already have what image sizes to reduce work only to add new sizes.

#3 @krogsgard
4 years ago

  • Type changed from defect (bug) to feature request

#4 follow-up: @nicasi
3 years ago

At the moment the urls of the images are inserted in the post with the dimensions appended (eg ...uploads/example-113x200.jpg) if I'm not mistaken. So after an image regeneration the urls with the old dimensions are still in the wp_posts table pointing to the old dimensions.

It might be an idea to decouple this a bit and retrieve the images like this: ...uploads/example.jpg?thumb or example.jpg?medium. (The sizes should get stored somewhere too. thumb = 200x200, medium = 450x450 etc) The images would still be regenerated but the front side would automatically reflect the new image sizes after regeneration without needing a complex search and replace in wp_posts.

Not sure if this is a good or a bad idea...

#5 in reply to: ↑ 4 @nicasi
3 years ago

Replying to nicasi:

Oh wait, the width and height are also in the wp_posts table on the img tag so these should get replaced too, bummer...

Btw, didn't the regenerate thumbnails plugin manage this also in the past? I cannot seem to get this working on a clean Wordpress install 4.5.3 with default theme. (Different topic, I'll ask on the wp forum)

#6 @lukecavanagh
3 years ago

@krogsgard

I know the WP-CLI has these options.

https://wp-cli.org/commands/media/regenerate/

Note: See TracTickets for help on using tickets.