{# templates/admin/field/vehicule_visuel_preview.html.twig #} {%- set public_base = field.getCustomOption('public_base') ?: '' -%} {%- set bucket = field.getCustomOption('bucket') ?: '' -%} {%- set raw_path = field.value is defined and field.value is not empty ? field.value : (entity is defined and entity.instance is defined and entity.instance is not null and entity.instance.storagePath is defined ? entity.instance.storagePath : '') -%} {%- set mode = field.getCustomOption('mode') ?: 'index' -%} {%- if public_base and bucket and raw_path -%} {%- set segments = raw_path|split('/') -%} {%- set encoded_segments = [] -%} {%- for segment in segments -%} {%- set encoded_segments = encoded_segments|merge([segment|url_encode]) -%} {%- endfor -%} {%- set url = public_base|trim('/') ~ '/storage/v1/object/public/' ~ bucket|url_encode ~ '/' ~ encoded_segments|join('/') -%} {%- else -%} {%- set url = '' -%} {%- endif -%} {%- set alt_text = (entity is defined and entity.instance is defined and entity.instance is not null and entity.instance.vehicule is not null) ? (entity.instance.vehicule ~ ' — ' ~ (entity.instance.angle|default('profil')|capitalize)) : 'Visuel véhicule' -%}