Commit 9488c668 authored by Pavel Janda's avatar Pavel Janda
Browse files

Added macros for absolute images url

No related merge requests found
Showing with 20 additions and 0 deletions
+20 -0
......@@ -18,8 +18,10 @@ class Macros extends Latte\Macros\MacroSet
$set = new static($compiler);
$set->addMacro('img', [$set, 'tagImg'], NULL, [$set, 'attrImg']);
$set->addMacro('imgAbs', [$set, 'tagImgAbs'], NULL, [$set, 'attrImgAbs']);
$set->addMacro('imgLink', [$set, 'linkImg']);
$set->addMacro('imgLinkAbs', [$set, 'linkImgAbs']);
return $set;
}
......@@ -31,15 +33,33 @@ class Macros extends Latte\Macros\MacroSet
}
public function tagImgAbs(Latte\MacroNode $node, Latte\PhpWriter $writer)
{
return $writer->write('$_img = $imageStorage->fromIdentifier(%node.array); echo "<img src=\"" . $baseUrl . "/" . $_img->createLink() . "\">";');
}
public function attrImg(Latte\MacroNode $node, Latte\PhpWriter $writer)
{
return $writer->write('$_img = $imageStorage->fromIdentifier(%node.array); echo \' src="\' . $basePath . "/" . $_img->createLink() . \'"\'');
}
public function attrImgAbs(Latte\MacroNode $node, Latte\PhpWriter $writer)
{
return $writer->write('$_img = $imageStorage->fromIdentifier(%node.array); echo \' src="\' . $baseUrl . "/" . $_img->createLink() . \'"\'');
}
public function linkImg(Latte\MacroNode $node, Latte\PhpWriter $writer)
{
return $writer->write('$_img = $imageStorage->fromIdentifier(%node.array); echo $basePath . "/" . $_img->createLink()');
}
public function linkImgAbs(Latte\MacroNode $node, Latte\PhpWriter $writer)
{
return $writer->write('$_img = $imageStorage->fromIdentifier(%node.array); echo $baseUrl . "/" . $_img->createLink()');
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment