Skip Navigation

[Resuelto] Image size not rendering properly

This support ticket is created hace 6 años, 5 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por kasiaG hace 6 años, 5 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#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>enlace oculto</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):

enlace oculto

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