I can display an image commerce file as a rendered file and selecting a view mode (Large), but how do I further style the image in the product display template file?

I can show the image using:

 if (!empty($product->commerce_file)):
                php endif; 
                print render($content['product:commerce_file']);

I can use a div to resize the image, but I wanted prefer to style it in img tags as I am mixing these images with other images in view displays that show Content as opposed to fields...

How would I achieve:
<img width="Xpx" height="Ypx" src="my commerce file" class="hover" alt="">

Comments

alpinemedia created an issue. See original summary.

alpinemedia’s picture

Issue summary: View changes
alpinemedia’s picture

Worked it out

if (!empty($product->commerce_file['und'][0]['uri'])) {
    $file_image = image_style_url("product_block",$product->commerce_file['und'][0]['uri']);
}

then used

<img height="X" src="<?php print $file_image; ?>" class="hover" alt="">

alpinemedia’s picture

Status: Active » Closed (fixed)