Skip Navigation

[Fermé] Using a predefined custom image size in custom 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 3 réponses, has 2 voix.

Last updated by Luo Yang Il y a 8 années et 9 mois.

Assigned support staff: Luo Yang.

Auteur
Publications
#25206

I have a custom type that uses a custom field for its image. In Settings>Media I created a custom image size using a plugin called Simple Image Size. I verified that the new custom image size option appears when adding an image to a regular post. I created a view template for my custom type, but when I add the image field to it, the custom image size doesn't appear as one of the options. All I see are the standard WordPress image sizes. Here's a test page, so you can see what I'm shooting for:
hidden link (In this case, I've uploaded an image at the exact size)

The popup is the custom type. I'm trying to make it easy for my client to create these little ads quickly. All they need to do is add copy to the custom fields and upload an image. I was hoping they wouldn't have to upload the exact size image, but rather could use the WP media size option to select a predefined size.

One more thing... For some reason I couldn't seem to apply a View archive, so ended up using a custom php template with 'echo(types_render_field)... to retrieve the data.

Thanks,
Eric

#25255

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

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

Hi Eric,

1) you can manually set the types image field shortcode parameter "size" to your custom image size,
like this:
[types field="my-test-image" size="my-custom-image-size" align="none"][/types]

More help: https://toolset.com/documentation/functions/#Image

2) to apply a View archive, please read our document "WordPress Archives – Customizing WordPress Archive Pages"
https://toolset.com/documentation/user-guides/normal-vs-archive-views/

Regards
Luo

#31395

Thanks, but what if I'm using it a a php template like so:

<img class="size-popup-ad-image" src="<?php echo(types_render_field("image", array("raw"=>"true"))); ?>" />

I tried using the class associated with that custom image size, but it's not working.

Thanks,
Eric

#31556

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

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

I can not duplicate same problem in my localhost, It seems a CSS problem, could you post here your live URL pages?

Le sujet ‘[Fermé] Using a predefined custom image size in custom field’ est fermé à de nouvelles réponses.