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

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>
| improve this answer | |
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>";
| improve this answer | |
  • no still that error – Anonymous Record Mar 6 at 13:03
  • Can you edit answer with last code after changes and error as well ? – Invigorate Systems Mar 6 at 13:08
  • Edited answer, please try that as well and see. – Invigorate Systems Mar 6 at 13:11
  • Parse error: syntax error, unexpected '$imgurl' (T_VARIABLE), expecting ',' or ';' in – Anonymous Record Mar 6 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>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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