MODX Revolution PHP Cross Reference Content Management Systems

Source: /core/model/modx/processors/element/tv/renders/web/output/image.class.php - 40 lines - 1411 bytes - Summary - Text - Print

   1  <?php
   2  /**
   3   * @package modx
   4   * @subpackage processors.element.tv.renders.mgr.output
   5   */
   6  class modTemplateVarOutputRenderImage extends modTemplateVarOutputRender {
   7      public function process($value,array $params = array()) {
   8          $images= $this->tv->parseInput($value, '||', 'array');
   9          $o= '';
  10          foreach ($images as $image) {
  11              if (!is_array($image)) {
  12                  $image= explode('==', $image);
  13              }
  14              $src= $image[0];
  15              if ($src) {
  16                  $attributes = array();
  17                  $attr = array(
  18                      'class' => $params['class'],
  19                      'src' => $src,
  20                      'id' => ($params['id'] ? $params['id'] : ''),
  21                      'alt' => htmlspecialchars($params['alttext']),
  22                      'style' => $params['style']
  23                  );
  24                  foreach ($attr as $k => $v) {
  25                      if (!empty($v)) {
  26                          $attributes[] = $k.'="'.$v.'"';
  27                      }
  28                  }
  29                  if (empty($attr['alt'])) $attributes[] = 'alt=""';
  30                  $attributes = implode(' ',$attributes);
  31                  $attributes .= ' '.$params['attributes'];
  32  
  33                  /* Output the image with attributes */
  34                  $o .= '<img '.rtrim($attributes).' />';
  35              }
  36          }
  37          return $o;
  38      }
  39  }
  40  return 'modTemplateVarOutputRenderImage';

title

Description

title

Description

title

Description

title

title

Body