File tree 5 files changed +17
-1
lines changed
resources/template/html/body
tests/Functional/tests/image-fullurl 5 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1
1
<img
2
- src =" {{ asset(node .value ) }}"
2
+ src =" {%- if node . value is external_target -%} {{ node . value }} {%- else -%} {{ asset(node .value ) }} {%- endif -% }"
3
3
{% if node.hasOption (' width' ) %}width =" {{ node.option (' width' ) }}" {% endif%}
4
4
{% if node.hasOption (' height' ) %}height =" {{ node.option (' height' ) }}" {% endif%}
5
5
{% if node.hasOption (' align' ) %}align =" {{ node.option (' align' ) }}" {% endif%}
Original file line number Diff line number Diff line change 14
14
namespace phpDocumentor \Guides \Twig ;
15
15
16
16
use League \Flysystem \Exception ;
17
+ use League \Uri \Uri ;
18
+ use League \Uri \UriInfo ;
17
19
use LogicException ;
18
20
use phpDocumentor \Guides \Meta \InternalTarget ;
19
21
use phpDocumentor \Guides \Meta \Target ;
26
28
use phpDocumentor \Guides \UrlGeneratorInterface ;
27
29
use Psr \Log \LoggerInterface ;
28
30
use RuntimeException ;
31
+ use Stringable ;
29
32
use Twig \Extension \AbstractExtension ;
30
33
use Twig \TwigFunction ;
31
34
use Twig \TwigTest ;
@@ -66,6 +69,10 @@ public function getTests(): array
66
69
/** @param mixed $value */
67
70
static fn (mixed $ value ): bool => $ value instanceof Node,
68
71
),
72
+ new TwigTest (
73
+ 'external_target ' ,
74
+ static fn (string |Stringable $ value ): bool => UriInfo::isAbsolute (Uri::createFromString ($ value )),
75
+ ),
69
76
];
70
77
}
71
78
Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ final class UrlGenerator implements UrlGeneratorInterface
33
33
public function absoluteUrl (string $ basePath , string $ url ): string
34
34
{
35
35
$ uri = UriFactory::createUri ($ url );
36
+ if (UriInfo::isAbsolute ($ uri )) {
37
+ return $ url ;
38
+ }
39
+
36
40
if (UriInfo::isAbsolutePath ($ uri )) {
37
41
return $ url ;
38
42
}
Original file line number Diff line number Diff line change
1
+ < p > Test</ p >
2
+ < img src ="https://img.shields.io/github/contributors/ORG/REPO " />
Original file line number Diff line number Diff line change
1
+ Test
2
+
3
+ .. image :: https://img.shields.io/github/contributors/ORG/REPO
You can’t perform that action at this time.
0 commit comments