You are here

protected function Markdown::_doImages_reference_callback in Markdown 7

* Callback to parse references image tags *

Parameters

array $matches: * @return string

1 method overrides Markdown::_doImages_reference_callback()
MarkdownExtra::_doImages_reference_callback in includes/MarkdownExtra.php
* Callback for referenced images *

File

includes/Markdown.php, line 848

Class

Markdown
Markdown 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}\"";
    }
    $result .= $this->empty_element_suffix;
    $result = $this
      ->hashPart($result);
  }
  else {

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