Skip Navigation

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

This support ticket is created vor 5 Jahren, 3 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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+00:00)

Dieses Thema enthält 4 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von yapM vor 5 Jahren, 3 Monaten.

Assistiert von: 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

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

Zeitzone: 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...?

#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

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

Zeitzone: 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?

#1292631

My issue is resolved now. Thank you!