You are here

protected function MarkdownExtra::_doImages_reference_callback in Express 8

* Callback for referenced images *

Parameters

array $matches: * @return string

Overrides Markdown::_doImages_reference_callback

File

vendor/michelf/php-markdown/Michelf/MarkdownExtra.php, line 959

Class

MarkdownExtra
Markdown Extra Parser Class

Namespace

Michelf

Code

protected function _doImages_reference_callback($matches) {
  $whole_match = $matches[1];
  $alt_text = $matches[2];
  $link_id = strtolower($matches[3]);
  if ($link_id == "") {
    $link_id = strtolower($alt_text);

    // for shortcut links like ![this][].
  }
  $alt_text = $this
    ->encodeAttribute($alt_text);
  if (isset($this->urls[$link_id])) {
    $url = $this
      ->encodeURLAttribute($this->urls[$link_id]);
    $result = "<img src=\"{$url}\" alt=\"{$alt_text}\"";
    if (isset($this->titles[$link_id])) {
      $title = $this->titles[$link_id];
      $title = $this
        ->encodeAttribute($title);
      $result .= " title=\"{$title}\"";
    }
    if (isset($this->ref_attr[$link_id])) {
      $result .= $this->ref_attr[$link_id];
    }
    $result .= $this->empty_element_suffix;
    $result = $this
      ->hashPart($result);
  }
  else {

    // If there's no such link ID, leave intact:
    $result = $whole_match;
  }
  return $result;
}