Support

Account

Home Forums Backend Issues (wp-admin) Possible to choose from different sets of image sizes in the media uploader?

Solved

Possible to choose from different sets of image sizes in the media uploader?

    • rpk

    • January 16, 2014 at 12:49 pm

    I have some kind of a tricky problem relating acf as well as the acf repeater field and wanted to ask if that goal is basically possible to accomplish.

    At the moment I try to get the following responsive image solution going in wordpress: http://premium.wpmudev.org/blog/diy-truly-responsive-images-on-your-wordpress-website/

    Normally you have a set of custom sizes you can specify inside the functions.php:

    add_image_size('res-small', 410, 9999);
    add_image_size('res-medium',750, 9999);
    add_image_size('res-large', 920, 9999);

    Problem is if you try to cover all the different aspect ratios of a layout, 3 custom images and the 3 standard wp ones won’t be enough. Basically you would need some sort of breakpoint sets with different sizes per set.

    I have a few custom post type with acfs inside the wp admin area. Each post type contains image uploaders (single and repeater ones).

    My question would be – would it be possible to offer some kind of selection inside the media uploader where the user would be able to choose between breakpoint sets. Basically with some sort of backend logic like that (easier to understand what I mean):

    <?php
    if($hook == breakpointset1) {
        add_image_size('bps1-small', 410, 9999);
        add_image_size('bps1-medium',750, 9999);
        add_image_size('bps1-large', 920, 9999);
    }
    else if ($hook == breakpointset1) {
        add_image_size('bps2-small', 360, 9999);
        add_image_size('bps2-middle', 520, 9999);
        add_image_size('bps2-middle', 820, 9999);
    }
    else {
        add_image_size('bp3-small', 220, 9999);
        add_image_size('bp3-middle', 820, 9999);
        add_image_size('bp3-large', 1200, 9999);
    }
    ?> 

    So that only the necessary images sizes for an uploaded image/images get created and not the whole selection of all available sizes. Would that be basically possible in WordPress and acf/acf repeater with a few additions to the functions.php? Or would be another plugin add on be more suitable to deal easier with that problem?

    Best regards Ralf

    • rpk

    • January 16, 2014 at 9:40 pm

    I’ve rethought the process again – basically the ideal solution would be based on the context the images are uploaded into (via which post type and which custom field the upload takes place) that the necessary breakpoint set is automatically applied and the custom set of images is generated accordingly.

    • Elliot

    • January 19, 2014 at 10:27 am

    Hi @rpk

    I’m not sure If I will be able to help you on this one, as I think this issue is not specifically related to ACF, but a general WP + responsive image size issue.

    Perhaps you could jump on stackoverflow to see what other devs have done int his situation?

    Thanks
    E

    • rpk

    • January 25, 2014 at 9:22 am

    Hi Elliot, that was just a general question, not that you already cover that kind of functionality in one of your premium plugins (i’ve overseen that already in one of my previous posts in here where you’ve pointed me to the repeater field – thanks again for that, the repeater field rocks). But indirectly you’ve answered my initial question here, since otherwise you’ve pointed me to one of your plugins. 😉 And I’ve already asked on stackoverflow but no useful answer yet. But finally had a new idea today which actually might work – implementing it right now and it seems to work. I only might have a follow up question, 100% acf related, later tonight, if I am unable to manage to get one specific thing working. But i will open a separate thread for it then. 😉 Thanks for now. Best regards Ralf

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.