Hi,
I have this code
<img class="" src="[wpv-post-field name='pyre_page_title_bar_bg']"/>
which shows an image within a <img> tag.
But this shows the image in its full resolution, and I'd like to get a smaller one.
In order to do this, I noticed I also have the image id with this code
[wpv-post-field name='pyre_page_title_bar_bg_id']
But now I wonder how to get the small version of the image based on the image ID.
How would this be achievable ?
Thank you.
Hello,
How do you setup/create the custom field "pyre_page_title_bar_bg"?
If it is a custom image field created with Types plugin, you can use Types shortcode to display the image in specific size, see our document:
https://toolset.com/documentation/customizing-sites-using-php/functions/#image
Attribute "size":
custom image size | 'full' | 'large' | 'medium' | 'thumbnail'
width and height will be ignored if size is set.
url:
'false'(default) | 'true'
true=output the url of the image instead of the html img tag.
Works with the size attribute to output the url of the re-sized image
Thank you.
The custom field is added by the theme Avada, in the page Avada options.
It stores the URL of the full image, and the ID of the image.
Based on those, I would need to find the URL of the small version of the image.
Thank you
There isn't such a built-in feature within Toolset plugin, I suggest you check it with Avada support:
hidden link
And you can consider custom codes too, for example:
https://toolset.com/forums/topic/get-id-of-attachment/#post-291761
Hello and thank you,
I found this function https://developer.wordpress.org/reference/functions/wp_get_attachment_image/
And tried to build it that way :
function recup_attachment($atts) {
$image_id = $atts["imgid"];
wp_get_attachment_image( $image_id, '400');
}
add_shortcode("le_thumb", "recup_attachment");
With shortcode
[le_thumb imgid="[wpv-post-field name='pyre_page_title_bar_bg_id']"]
but with no result. Nothing appears in frontend, and there is no errors in log files neither...
Thank you.
Since it is a custom PHP codes problem, please provide a test site with the same problem, also point out the problem page URL and where I can edit your PHP codes, I need to test and debug it in a live website, thanks