Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Jiří Ferkl
image-storage
Commits
9488c668
Commit
9488c668
authored
9 years ago
by
Pavel Janda
Browse files
Options
Download
Patches
Plain Diff
Added macros for absolute images url
parent
02f7fc68
master
nette-3
v1.1.3
v1.1.2
v1.1.1
v1.1.0
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Macros/Macros.php
+20
-0
src/Macros/Macros.php
with
20 additions
and
0 deletions
+20
-0
src/Macros/Macros.php
+
20
−
0
View file @
9488c668
...
...
@@ -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()'
);
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets