redrum Posted October 20, 2022 Share Posted October 20, 2022 (edited) How can I get the real image path/folder location for the product images in a smarty .tpl-file? Product images are stored with the following structure: Product image id: 1234 Location: www.url.com/img/p/1/2/3/4/1234.jpg 'www.url.com/img/p/1/2/3/4/1234.jpg' is want I want to output in the .tpl-file. I managed to get the folder structure and file name (ie: 1/2/3/4/1234.jpg) in smarty with the following code: {$product.id_image|regex_replace:'/.*-/':''|spacify:'/'}/{$product.id_image|regex_replace:'/.*-/':''}.jpg But I believe regex_replace is a bad practice to use in template files. Edited October 20, 2022 by redrum Title updated with [SOLVED] (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted October 20, 2022 Share Posted October 20, 2022 (edited) Hi. {if $product.id_image} {$urls.img_prod_url}{Image::getImgFolderStatic($product.id_image)}{$product.id_image}.jpg {/if} Edited October 20, 2022 by 4you.software (see edit history) 1 Link to comment Share on other sites More sharing options...
redrum Posted October 20, 2022 Author Share Posted October 20, 2022 4 hours ago, 4you.software said: Hi. {if $product.id_image} {$urls.img_prod_url}{Image::getImgFolderStatic($product.id_image)}{$product.id_image}.jpg {/if} The output for this becamehttps://www.url.com/img/p/99-1234.jpg ( https://www.url.com/img/p/ [product id] - [id image] .jpg ) But I managed to get folder location with this code: {Image::getImgFolderStatic($product.cover.id_image)}{$product.cover.id_image}.jpg Thanks for pointing me in the right direction. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now