Search code examples
imagesliderconcrete5concrete5-8.x

Load image in style (default slider) Concrete5


In the custom slider in Concrete5 8.x Images are loaded with $tag

<?php $f = File::getByID($row['fID']) ?>
   <?php if (is_object($f)) {
       $tag = Core::make('html/image', array($f, false))->getTag();
       if ($row['title']) {
          $tag->alt($row['title']);
       } else {
          $tag->alt("slide");
   }
   echo $tag;
?>

I like to load the images in the following way (in style"..."

<li><img src="data:image/gif;base64,xxx" style="background-image: url('images/slider-image.jpg');"></li>

I there an easy way to change the way the images are loaded and call the location in the style? Like the following example:

<li><img src="data:image/gif;base64,xxx" style="background-image: 
url('CODE_TO_IMAGE_URL');"></li>

Solution

  • What about this code?

    <?php
    $f = File::getByID($row['fID']);
    if ($f) {
        ?>
        <li>
            <img src="data:image/gif;base64,xxx" style="background-image: url('<?= $f->getRelativePath() ?>')" />
        </li>
        <?php
    }
    ?>