0

This is my code

<div class="gallery-placeholder _block-content-loading" data-gallery-role="gallery-placeholder">
<?php /* @escapeNotVerified */
$json=$block->getGalleryImagesJson();
$array = json_decode($json,true);
foreach($array as $item)
{
    $imgurl = $item['full'];
    echo '<img alt="main product photo" class="gallery-placeholder__image" ".$imgurl['url']. "/>';
   <br>
}
?> 
</div>

and I am getting error on this line

echo '<img alt="main product photo" class="gallery-placeholder__image" ".$imgurl['url']. "/>';

as

Parse error: syntax error, unexpected 'url' (T_STRING), expecting ',' or ';' in C:\wamp64\www\ekelund1692\app\design\frontend\Pronko\ekelund\Magento_Catalog\templates\product\view\gallery.phtml on line 8

3 Answers 3

0

replace below code hope it's work for you

<div class="gallery-placeholder _block-content-loading" data-gallery-role="gallery-placeholder">
    <?php /* @escapeNotVerified */
    $json=$block->getGalleryImagesJson();
    $array = json_decode($json,true); ?>
    <?php foreach($array as $item): ?>
        <?php 
        $imgurl = $item['full'];
        echo '<img alt="main product photo" class="gallery-placeholder__image" src="'.$imgurl['url'].'">'; 
        ?>
        <br>
    <?php endforeach; ?>
</div>
1
  • By adding this code div class disappears Commented Mar 6, 2020 at 13:03
0

You used image tag without src attribute.

Change your line to :

<?php echo "<img alt='main product photo' class='gallery-placeholder_image' src='".$imgurl['url']."' />"; ?>

And also remove <br> tag after error line, as direct <br> tag inside PHP is not allowed. either remove or change it to :

echo "<br>";
4
  • no still that error Commented Mar 6, 2020 at 13:03
  • Can you edit answer with last code after changes and error as well ? Commented Mar 6, 2020 at 13:08
  • Edited answer, please try that as well and see. Commented Mar 6, 2020 at 13:11
  • Parse error: syntax error, unexpected '$imgurl' (T_VARIABLE), expecting ',' or ';' in Commented Mar 6, 2020 at 13:44
0

try this hope it works.

  <div class="gallery-placeholder _block-content-loading" data-gallery-role="gallery-placeholder">
    <?php /* @escapeNotVerified */
    $json=$block->getGalleryImagesJson();
    $array = json_decode($json,true);
    foreach($array as $item)
    {
        $imgurl = $item['full'];
        echo '<img alt="main product photo" class="gallery-placeholder__image" src="'.$imgurl['url'].'"/>';
       echo "<br/>";
    }
    ?> 
    </div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.