Skip Navigation

[Resolved] Image size not rendering properly

This support ticket is created 6 years, 5 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by kasiaG 6 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#916409

I have a custom post Type (Organizations) with a custom image field (Logo). I am trying to output the thumbnail size of this image in a template. I am using the following code to retrieve the HTML for:

$logo = types_render_field('logo', array('size' => 'thumbnail','class' => 'company_logo'));

This outputs the following HTML:

<img src="<em><u>hidden link</u></em>" class="attachment-thumbnail company_logo" scale="0">

However, this seems to be rendering a Toolset-specific image size that is not cropped to spec. If I were to render the same image as a WordPress featured image, it would instead use this URL (source of a thumbnail cropped to spec using the Post Thumbnail Editor plugin):

hidden link

How do I fix this, and force the output to use the actual WordPress thumbnail size, and not the Toolset-specific thumbnail size?

#916459

Hello,

I assume you are going to do a crop the image from left horizontally.

If it is, there isn't such a built-in feature within Types image field, see our document:
https://toolset.com/documentation/customizing-sites-using-php/functions/#image
No option to "crop the image from left horizontally".

And, it is possible with feature image of Views shortcode:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-featured-image
crop_horizontal (opt):
'left' | 'center' | 'right'

You might consider to use feature image field to replace the logo custom image field.

#916827

I figured this out myself. Here is the solution:

$logo_raw = types_render_field('logo', array('output' => 'raw'));
$logo_id = get_img_id_from_url($logo_raw);
$logo = wp_get_attachment_image($logo_id, 'thumbnail');

if ($logo) { echo $logo; }