Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

How to create different sized image sets based on the context an image is uploaded in the media upload

At the moment i am researching if the following problem would be solve-able in Wordpress; but somehow the codex as well blog posts and google research haven't brought me one step further. The thing i was looking for is if there is a way, based on which context an image is uploaded inside the Wordpress media uploader (in my case in which custom post type and advance custom field the image upload button is located- in the regular advanced custom fields plugin as well as the repeater field), that different sets of image sizes are created.

What i am trying to say if i upload an images via the image upload button in my custom post type "portfolio" in the custom field "overview image" there should be created e.g. 3 images:

240x240
340x340
450x450

if i upload and image in the custom post type "portfolio" in the custom field "worksamples" 5 images should be created instead:

310x80
420x120
550x180
640x220
750x280

So that the standard automated image version generation (thumbnail, medium, large) is prevented and only that set of images defined for the specific post type and custom field is created. So not dozens of image versions covering every layout scenario created for every image but only that few necessary.

And i would prefer not to create the images on demand like in a few plugins out there. I would prefer the necessary images created right on upload like described.

So would it be basically possible to extend Wordpress to provide that kind of functionality? And what are the catchwords i would have to read into? Appreciate any hints pointing me in the right direction. Thanks and best regards Ralf