getHTML() публичный Метод

Attributes can be added as a parameter. Attributes containing illigal characters are ignored. Width and Height attribute can be overridden. SRC-attribute not. Values of attributes are escaped.
public getHTML ( array $options = [], array $removeAttributes = [] ) : string
$options array Custom configurations and HTML attributes.
$removeAttributes array Listof key-value pairs of HTML attributes that should be removed
Результат string IMG-element with at least the attributes src, width, height, alt.
Пример #1
0
 /**
  * @see Document\Tag\TagInterface::frontend
  * @return string
  */
 public function frontend()
 {
     if (!is_array($this->options)) {
         $this->options = [];
     }
     $image = $this->getImage();
     if ($image instanceof Asset) {
         if (isset($this->options["thumbnail"]) && $this->options["thumbnail"] || $this->cropPercent) {
             // create a thumbnail first
             $autoName = false;
             $thumbConfig = $image->getThumbnailConfig($this->options["thumbnail"]);
             if (!$thumbConfig && $this->cropPercent) {
                 $thumbConfig = new Asset\Image\Thumbnail\Config();
             }
             if ($this->cropPercent) {
                 $this->applyCustomCropping($thumbConfig);
                 $autoName = true;
             }
             if (isset($this->options["highResolution"]) && $this->options["highResolution"] > 1) {
                 $thumbConfig->setHighResolution($this->options["highResolution"]);
             }
             // autogenerate a name for the thumbnail because it's different from the original
             if ($autoName) {
                 $hash = md5(Serialize::serialize($thumbConfig->getItems()));
                 $thumbConfig->setName($thumbConfig->getName() . "_auto_" . $hash);
             }
             $deferred = true;
             if (isset($this->options["deferred"])) {
                 $deferred = $this->options["deferred"];
             }
             $thumbnail = $image->getThumbnail($thumbConfig, $deferred);
         } else {
             // we're using the thumbnail class only to generate the HTML
             $thumbnail = new Asset\Image\Thumbnail($image);
         }
         $attributes = array_merge($this->options, ["alt" => $this->alt, "title" => $this->alt]);
         $removeAttributes = [];
         if (isset($this->options["removeAttributes"]) && is_array($this->options["removeAttributes"])) {
             $removeAttributes = $this->options["removeAttributes"];
         }
         // thumbnail's HTML is always generated by the thumbnail itself
         return $thumbnail->getHTML($attributes, $removeAttributes);
     }
 }