Using the foreach loop to get the wpcf-img-field and creating own image tag which require the img height/width attributes.
How do i do that with toolset?
Nigel
Supporter
Languages:
English (English )
Spanish (Español )
Timezone:
Europe/London (GMT+00:00)
I'm not sure what exactly it is you need help with.
Setting up a foreach loop to generate several image tags where you have an image field that accepts multiple values, or specifying the height and width of the image you want to display (e.g. the "medium" size), or detecting the height and width of the original source image...?
sorry i need help with
specifying the height and width of the image you want to display (e.g. the "medium" size)
Nigel
Supporter
Languages:
English (English )
Spanish (Español )
Timezone:
Europe/London (GMT+00:00)
You would need to write custom shortcodes to output the actual height and width of the images for the size you specify.
You can read about writing custom shortcodes here: https://developer.wordpress.org/plugins/shortcodes/
You'll need to pass the slug of the image field.
Your code can then use attachment_url_to_postid() to retrieve the image ID from the field value (which is the full-sized URL): https://developer.wordpress.org/reference/functions/attachment_url_to_postid/
You can then use wp_get_attachment_image_src() to get an array of image properties for the specified size, including the height and width: https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/
You have a good reason for building the img tag manually rather than outputting it with a Types shortcode, yes?
My issue is resolved now. Thank you!