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?
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.
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; }