|
13 | 13 | # - string title: used as title if set, otherwise caption from the image is used
|
14 | 14 | # - bool dimensions: if set to true, will add width and height to img tag. false by default.
|
15 | 15 | # - string link_href: if set, will wrap img tag with link (<a> tag)
|
| 16 | + # - string link_target: default empty, example: '_blank' |
| 17 | + # - string link_class: default empty, adds css class to the link |
| 18 | + # - string link_title: default empty, adds title attribute to the link |
16 | 19 | #}
|
17 | 20 | {% block ngremotemedia_field %}
|
18 | 21 | {% set format = parameters.alias ?? parameters.format|default('') %}
|
|
23 | 26 | {% set otherConst = constant('Netgen\\Bundle\\RemoteMediaBundle\\Core\\FieldType\\RemoteMedia\\Value::TYPE_OTHER') %}
|
24 | 27 |
|
25 | 28 | {% set link_href = parameters.link_href|default('') %}
|
| 29 | + {% set link_target = parameters.link_target|default('') %} |
| 30 | + {% set link_class = parameters.link_class|default('') %} |
| 31 | + {% set link_title = parameters.link_title|default('') %} |
26 | 32 |
|
27 | 33 | {% if field.value.mediaType == imageConst %}
|
28 | 34 | {% if parameters.alt_text is defined and parameters.alt_text is not empty %}
|
29 | 35 | {% set alt_text = parameters.alt_text %}
|
30 | 36 | {% else %}
|
31 | 37 | {% set alt_text = field.value.metaData.alt_text|default('') %}
|
32 | 38 | {% endif %}
|
| 39 | + |
| 40 | + {% if alt_text is empty %} |
| 41 | + {% set alt_text = content.name %} |
| 42 | + {% endif %} |
| 43 | + |
33 | 44 | {% if parameters.title is defined and parameters.title is not empty %}
|
34 | 45 | {% set title = parameters.title %}
|
35 | 46 | {% else %}
|
|
41 | 52 | {% endif %}
|
42 | 53 |
|
43 | 54 | {% if link_href is not empty %}
|
44 |
| - <a href="{{ link_href }}"> |
| 55 | + <a href="{{ link_href }}" |
| 56 | + {% if link_target is not empty %}target="{{ link_target }}" {% if link_target == '_blank' %}rel="nofollow noopener noreferrer"{% endif %}{% endif %} |
| 57 | + {% if link_class is not empty %}class="{{ link_class }}{% endif %} |
| 58 | + {% if link_title is not empty %} title="{{ link_title }}" {% endif %} |
| 59 | + aria-label="{{ alt_text }}" > |
45 | 60 | {% endif %}
|
46 | 61 |
|
47 | 62 | {% if variation is defined and variation.url%}
|
|
0 commit comments