WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 6 months ago

#13372 new enhancement

Separate Image sizes for different post types

Reported by: brandondove Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Media Keywords: needs-patch dev-feedback close
Focuses: Cc:

Description

Would be nice, especially moving forward with custom post types to have the ability to set different image sizes using an additional parameter of add_image_size() for different post types: Page, Post, and Custom.

Change History (14)

comment:1 nacin3 years ago

  • Milestone changed from Awaiting Review to Future Release

comment:2 billerickson2 years ago

  • Keywords changed from post thumbnails, add_image_size, custom post types, image cropping to post thumbnails add_image_size, custom post types, image cropping

I also think this would be very useful. I'm often creating post types that require multiple image sizes (like a Gallery post type), but there's no reason to resize every image uploaded to that size.

comment:3 billerickson2 years ago

  • Cc bill.erickson@… added
  • Keywords changed from post thumbnails add_image_size, custom post types, image cropping to post thumbnails add_image_size custom post types, image cropping

comment:4 jaredatch2 years ago

  • Cc jared@… added
  • Keywords changed from post thumbnails add_image_size custom post types, image cropping to post thumbnails add_image_size custom post types image cropping

comment:5 billerickson2 years ago

  • Keywords needs-patch added; post thumbnails add_image_size custom post types image cropping removed

getting rid of all these keywords

comment:6 follow-up: markoheijnen19 months ago

  • Keywords dev-feedback close added

I think this ticket can be closed since the problem isn't the ability to define a post type to an image size. The problem is that everything is getting created on the fly. And we should find a way to do that. See #15311

comment:7 in reply to: ↑ 6 MikeSchinkel19 months ago

  • Cc mike@… added

Replying to markoheijnen:

I think this ticket can be closed since the problem isn't the ability to define a post type to an image size.

I will disagree with that. Our team has implemented what is effectively a register_image_type() function and it is both solving a very real need and working extremely well for us.

There are many cases in plugins you need to be limit based on image type or to validate on image type. If I need to give a user the ability to upload an image for a custom post types, let's say for a "Case Study" I would like to be able to limit them to cropping to aspect ratios that are appropriate for the "case study featured image", for example.

This requirement is pervasive in the work we are doing for our main clients. We have it built it to our plugins but we'd far prefer to see that requirement handled by an API in core, and I'm confident that core would find many uses for leveraging it over coming releases.

The problem is that everything is getting created on the fly. And we should find a way to do that. See #15311

Yes, I can see that as another issue too (one our team has also implemented), but it's a requirement that is orthogonal to image types.

comment:8 markoheijnen19 months ago

It seems you go the other direction now at the ticket described. We are talking about generate a certain image size for a certain post type.
Also that is something that can probably be done in WordPress.

I still think #15311 is the way to go. You can select there which images to auto generate and which not. This ticket will need that since it will be a pain in the beginning for adding new sizes for existing content. Since plugins need to build on the demand.

comment:9 helen16 months ago

#23105 was marked as a duplicate.

comment:10 toscho16 months ago

  • Cc info@… added

comment:11 follow-up: aaronholbrook16 months ago

Coming in from #23105: as I suggested in the dev chat for the 3.6 roadmap today, being able to limit image sizes to specific post types is a good idea and received positive feedback from both MarkJaquith and danielbachhuber for inclusion in 3.6.

MikeSchinkel, would you be able to share your code for your register_image_type() function/etc?

Version 0, edited 16 months ago by aaronholbrook (next)

comment:12 markoheijnen16 months ago

First to temper your expectations. There isn't really said in words that this should be include for 3.6.

My arguments still stands that the problem isn't in define a post type to an image size but with the ability to generate an image size on-the-fly or just by simpel code. Jkudish also mentioned this in the chat:

"what if the image is uploaded in the media library w/out being attached to a post? or what if it's attached to 2-3 different post types?".

That is from my point of view a problem that isn't easy to fix or even not fixable. In my cases I never attach an image to a post. That doesn't make sense.

As I mentioned you already can create images with WordPress without the need of add_image_size. It's even more easier now in 3.5 with (WP_Image_Editor) then ever before. I do have some ideas to make it even more easier to generate images with a few lines of code and that it's added to the metadata array of a certain image.

As conclusion is close this ticket in favor of others. Also what is next? Add an image size to a post format, maybe a taxonomy etc.

comment:13 in reply to: ↑ 11 MikeSchinkel16 months ago

Replying to aaronholbrook:

MikeSchinkel, would you be able to share your code for your register_image_type() function/etc?

I've been planning to share it after refactoring out the code not related to the core approach but client projects have continued to get in the way. It's still on my todo list though...

comment:14 DrewAPicture6 months ago

  • Cc xoodrew@… added
Note: See TracTickets for help on using tickets.