Reputation: 107
I'm using jQueryZoom that need two images to be displayed like this (one image for the 'a' tag and another for the 'img'):
<a href="images/BIGIMAGE.JPG">
<img src="images/SMALLIMAGE.JPG">
</a>
But I need bring those images from two diferents directories from MySQL (the default directory: 'zoom' and the directory: 'normal'. So I'm trying this on my HTML body:
<?php if ( $imagePath = $results02['adaptador']->getImagePathFrontend() && $imagePathNormal = $results02['adaptador']->getImagePathFrontend( IMG_TYPE_NORMAL ) ) { ?>
<a href="<?php echo $imagePath ?>" rel='gal1' id="demo1" >
<img src="<?php echo $imagePathNormal ?>" />
</a>
<?php } ?>
It's bringing me just the second one. In the first one it's returns a true value (1). This is the code after load the page on the browser:
<a href="1" rel='gal1' id="demo1" >
<img src="../../images/produtos/adaptadores/normal/Adaptador 2P.png" />
</a>
Why the 'if' is returning true on the first option instead of the image path like in the second one?
Upvotes: 2
Views: 67
Reputation: 10040
Either set image path outside or put parenthesis around it. your order of operations is probably confusing you
<?php
$imagePath = $results02['adaptador']->getImagePathFrontend();
if ( $imagePath && $imagePathNormal = $results02['adaptador']->getImagePathFrontend( IMG_TYPE_NORMAL ) ) { ?>
<a href="<?php echo $imagePath ?>" rel='gal1' id="demo1" ><img src="<?php echo $imagePathNormal ?>" /></a>
<?php } ?>
Upvotes: 1
Reputation: 1017
You have to group the assignments separately. Right now you're assigning to $imagePath
the result of a boolean operation.
if ( ($imagePath = $results02['adaptador']->getImagePathFrontend()) &&
($imagePathNormal = $results02['adaptador']->getImagePathFrontend( IMG_TYPE_NORMAL )) )
{
// ...
}
Upvotes: 3