I was looking for the same thing and tried the example above, was the good way but no so simple for me, finally it done this :
1 : create the checkbox field with the different size
(thumbnail : thumbnail
medium : medium
large : large
full : full
custom-size : custom-size)
2 : the code to display
<?php $attachment_id = get_field('image'); $field = get_field_object('size'); $value = get_field('size'); $label = $field['choices'][ $value ]; $image = wp_get_attachment_image_src( $attachment_id, $label ); // url = $image; // width = $image; // height = $image; ?> <a href="<?php echo $image; ?>" class="fancybox"><img src="<?php echo $image; ?>" /></a>
It works good and the check box very easy to use !
Now have to find a solution to the Gallery field…
We really need this feature, without all the pictures are full size !! it looks a detail but when you have a lot of pictures to manage you understand how important it is. Many Thanks ! ACF is great !
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.