Skip Navigation

[Gelöst] Create own manuaimage tag but how to get the height/width metadata with toolset?

This support ticket is created vor 4 Jahre, 9 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 4 Antworten, has 2 Stimmen.

Last updated by yapM vor 4 Jahre, 9 Monate.

Assisted by: Nigel.

Author
Artikel
#1290963

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?

#1291411

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01: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...?

#1291465

sorry i need help with

specifying the height and width of the image you want to display (e.g. the "medium" size)

#1291593

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01: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?

#1292631

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.