Skip Navigation

[Resolved] I'm trying to set up a alt and title tag on my image field

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.

This topic contains 5 replies, has 2 voices.

Last updated by lauraS-3 5 years ago.

Assigned support staff: Luo Yang.

Author
Posts
#435076

I want alt and title to picked up from the media library not manually entered in PHP files.

<?php echo types_render_field('image' , array('alt'=> ' ' , 'title' => ' ' , 'class' => 'attachment-large center-block img-responsive wp-post-image')); ?>

Thanks

#435181

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Dear laura,

Please try this:

<?php echo types_render_field('image' , array('alt'=> ' %%ALT%%' , 'title' => '%%TITLE%% ' , 'class' => 'attachment-large center-block img-responsive wp-post-image')); ?

More help:
https://toolset.com/documentation/customizing-sites-using-php/functions/#image
For the alt and title attributes, you can also use placeholders to output the values of standard image fields added in WordPress: %%TITLE%%, %%ALT%%, %%CAPTION %%, and %%DESCRIPTION%%.

#435281

Hi That didn't make any difference ....

#435491

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

I tested it in my localhost, it works fine, please check these in your website:
1) in above codes, replace the field slug "image" with the your custom field slug
2) deactivate other plugins and switch to wordpress default theme, and test again

#435693

actually It worked.

#435696

Thanks for help.