[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/fields/imagelist/tmpl/ -> imagelist.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  Fields.Imagelist
   6   *
   7   * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  defined('_JEXEC') or die;
  12  
  13  use Joomla\CMS\Image\Image;
  14  
  15  if ($field->value == '') {
  16      return;
  17  }
  18  
  19  $class = $fieldParams->get('image_class');
  20  
  21  if ($class) {
  22      // space before, so if no class sprintf below works
  23      $class = ' class="' . htmlentities($class, ENT_COMPAT, 'UTF-8', true) . '"';
  24  }
  25  
  26  $value  = (array) $field->value;
  27  $buffer = '';
  28  
  29  foreach ($value as $path) {
  30      if (!$path || $path == '-1') {
  31          continue;
  32      }
  33  
  34      $imageFilePath = htmlentities($path, ENT_COMPAT, 'UTF-8', true);
  35  
  36      if ($fieldParams->get('directory', '/') !== '/') {
  37          $imageInfo = Image::getImageFileProperties(JPATH_ROOT . '/images/' . $fieldParams->get('directory') . '/' . $imageFilePath);
  38  
  39          $buffer .= sprintf(
  40              '<img loading="lazy" width="%s" height="%s" src="images/%s/%s"%s alt="">',
  41              $imageInfo->width,
  42              $imageInfo->height,
  43              $fieldParams->get('directory'),
  44              $imageFilePath,
  45              $class
  46          );
  47      } else {
  48          $imageInfo = Image::getImageFileProperties(JPATH_ROOT . '/images/' . $imageFilePath);
  49  
  50          $buffer .= sprintf(
  51              '<img loading="lazy" width="%s" height="%s" src="images/%s"%s>',
  52              $imageInfo->width,
  53              $imageInfo->height,
  54              $imageFilePath,
  55              $class
  56          );
  57      }
  58  }
  59  
  60  echo $buffer;


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer