Third question, same topic ; )
Well, I have a PHP snippet that show's the 2nd image in an array. There are 4 images in that array:
Image 1: Outfit
Image 2: Jacket
Image 3: Shirt
Image 4: Jeans
So the 2nd Image is the one that is always suppose to be shown on a Product List page, which is the Jacket.
The problem is, that some products do not have the Outfit image, so there are only 3 images in that array:
Image 1: Jacket
Image 2: Shirt
Image 3: Jeans
The PHP Snippet that I am using is:
$images = $product->images;
if (count($images) > 0):
$image_1 = $images->getThumbnailPath(235, 'auto');
<a href="<?= $product->page_url('/product') ?>">
<img src="<?= $image_1 ?>" alt="<?= h($product->name) ?>" />
<h4><?= h($product->name) ?></h4>
<? endif ?>
The image array starts at 0
So if there are only 3 images in the array, then the image that will be shown on the Product List is the Shirt, and not the Jacket.
I know this may be confusing but, is there a way for me to show the 1st image if there are 3 images in the array, and if there are 4 images in the array, then the 2nd image show from that array?