I am wondering if it possible to somehow, add a custom image size into an inline style.
For example, I would usually use:
<section id="example" style="background-image:url(<?php the_field('field_name'); ?>);"></section>
along with the url option. However, I want to have a background image, but also specify the crop size.
Is this even possible? Thanks in advance to anyone who might be able to help. 🙂
No, when returning the url the_field() will only return the full size url.
In order to use a specific size you’ll need to do one of 2 things.
1) Return an image array and then use that image size
get_field() instead of
the_field() see the doc https://www.advancedcustomfields.com/resources/image/
2) Return an image ID and use https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/ and then output the url from that