Page 1 of 1

SOLVED Products Module Accessing _products/

Posted: Wed Nov 11, 2020 3:08 pm
by montedavis
Hello,

I'm using the products module and I'm trying to make image management easy for my client by having them upload images via a custom field definition named "case-study-detail-image"

When an image is uploaded the name of the image is added as the field value, which makes sense. I'm having trouble displaying the actual image on the frontend of the site as I don't know how to access the directory where the image is stored. If I go to the "fields" tab of an item I can see the name of the image and if I hover over the image I can see the path to the upload directory for that specific product image:

/uploads/_products/product_1/product_1_image.jpg

How do I find the smarty variables to construct the path?

I tried adding the following troubleshooting tags but did not see the image path.
{get_template_vars}
{$var|print_r}
{$item|print_r}
{$entry|print_r}

I understand I could use the "images" tab but adds images to an "album" and I don't understand how to pull a specific image from the album images array, and it may be too confusing to explain how to use multiple images to the client.

Thank you,

Monte

Re: Products Module Accessing _products/

Posted: Wed Nov 11, 2020 4:04 pm
by montedavis
I figured it out...

{if !empty($entry->fields)}
{foreach from=$entry->fields item='field'}
{if $field->name == 'case-study-detail-image'}
<div class="case-study-image"><img class="case-studies-detail-image" src="/{uploads_url}/_products/product_{$entry->id}/{$field->value}"><div>
{/if}
{/foreach}
{/if}