Skip to content

Commit

Permalink
Configure asset packages and add package to asset call
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny van Wijk authored and dannyvw committed Oct 22, 2020
1 parent bdacee7 commit 19fc3c4
Show file tree
Hide file tree
Showing 20 changed files with 53 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="submenu__item">
<a href="{{ path('_slug', { 'url': item['nt'].url }) }}" class="submenu__link">
{% if item['page'].menuImage is defined and item['page'].menuImage is not empty %}
<img src="{{ item['page'].menuImage.url|imagine_filter('optim') }}" alt="" class="submenu__img">
<img src="{{ asset(item['page'].menuImage.url|imagine_filter('optim'), 'media') }}" alt="" class="submenu__img">
{% endif %}
<h2 class="submenu__title">{{ item['nt'].title }}</h2>
{% if item['page'].menuDescription is defined and item['page'].menuDescription %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<figure class="header-visual">
{% if resource.backgroundImage is not empty %}
<img src="{{ asset(resource.backgroundImage.url|imagine_filter('optim')) }}" class="header-visual__img">
<img src="{{ asset(resource.backgroundImage.url|imagine_filter('optim'), 'media') }}" class="header-visual__img">
{% endif %}

<figcaption class="header-visual__content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<figure class="col-sm-6 service-pp__image">
{% if resource.image is not empty %}
<img src="{{ asset(resource.image.url|imagine_filter('optimpng')) }}" alt="{{ resource.title }}">
<img src="{{ asset(resource.image.url|imagine_filter('optimpng'), 'media') }}" alt="{{ resource.title }}">
{% endif %}
</figure>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
{% endif %}
</p>
<p class="sub-footer__credentials">
Created by <a href="http://www.kunstmaan.be" class="sub-footer__credentials__link"><img src="/frontend/img/general/logo-kunstmaan.svg" alt="Kunstmaan" class="sub-footer__credentials__img"></a>
Created by <a href="http://www.kunstmaan.be" class="sub-footer__credentials__link"><img src="{{ asset('/frontend/img/general/logo-kunstmaan.svg') }}" alt="Kunstmaan" class="sub-footer__credentials__img"></a>
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{# Logo #}
{% set homepagePageNode = nodemenu.getRootNodeMenuItem() %}
<a href="{{ path('_slug', { 'url': homepagePageNode.slug }) }}" class="main-header__logo">
<img src="/frontend/img/demosite/logo-thecrew.svg" alt="The Crew" class="main-header__logo__img">
<img src="{{ asset('/frontend/img/demosite/logo-thecrew.svg') }}" alt="The Crew" class="main-header__logo__img">
</a>


Expand Down Expand Up @@ -52,7 +52,7 @@
{# Logo #}
{% set homepagePageNode = nodemenu.getNodeByInternalName('homepage') %}
<a href="{{ path('_slug', { 'url': homepagePageNode.slug }) }}" class="main-header__logo">
<img src="/frontend/img/demosite/logo-thecrew.svg" alt="The Crew" class="main-header__logo__img">
<img src="{{ asset('/frontend/img/demosite/logo-thecrew.svg') }}" alt="The Crew" class="main-header__logo__img">
</a>


Expand Down Expand Up @@ -121,7 +121,7 @@
{# Logo #}
{% set homepagePageNode = nodemenu.getNodeByInternalName('homepage') %}
<a href="{{ path('_slug', { 'url': homepagePageNode.slug }) }}" class="main-header__logo">
<img src="/frontend/img/general/logo-kunstmaan.svg" alt="Kunstmaan" class="main-header__logo__img">
<img src="{{ asset('/frontend/img/general/logo-kunstmaan.svg') }}" alt="Kunstmaan" class="main-header__logo__img">
</a>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% endif %}

<p class="download-pp">
<a href="{{ absolute_url(asset(resource.media.url)) }}" target="_blank" class="download">{{ name }}</a>
<a href="{{ absolute_url(asset(resource.media.url, 'media')) }}" target="_blank" class="download">{{ name }}</a>
<span>| {{ resource.media.contentTypeShort }} {{ resource.media.getFileSize() }}</span>
</p>
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
{% set imgUrl = '' %}

{% if type in ['svg', 'gif'] %}
{% set imgUrl = absolute_url(asset(image)) %}
{% set imgUrl = absolute_url(asset(image, 'media')) %}
<img src="{{ imgUrl }}"{% if altText %} alt="{{ altText }}"{% endif %} />
{% else %}
{% set imgUrl_huge = asset(image | imagine_filter('image_huge_' ~ type)) %}
{% set imgUrl_big = asset(image | imagine_filter('image_big_' ~ type)) %}
{% set imgUrl_medium = asset(image | imagine_filter('image_medium_' ~ type)) %}
{% set imgUrl_small = asset(image | imagine_filter('image_small_' ~ type)) %}
{% set imgUrl_huge = asset(image | imagine_filter('image_huge_' ~ type), 'media') %}
{% set imgUrl_big = asset(image | imagine_filter('image_big_' ~ type), 'media') %}
{% set imgUrl_medium = asset(image | imagine_filter('image_medium_' ~ type), 'media') %}
{% set imgUrl_small = asset(image | imagine_filter('image_small_' ~ type), 'media') %}
{% set srcSet = imgUrl_small ~ ' 400w, ' ~ imgUrl_medium ~ ' 600w, ' ~ imgUrl_big ~ ' 1200w, ' ~ imgUrl_huge ~ ' 2400w' %}

{#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
{% set imgUrl = '' %}

{% if type in ['svg', 'gif'] %}
{% set imgUrl = absolute_url(asset(image)) %}
{% set imgUrl = absolute_url(asset(image, 'media')) %}
<img class="video-pp__link__img" src="{{ imgUrl }}"{% if altText %} alt="{{ altText }}"{% endif %} />
{% else %}
{% set imgUrl_huge = asset(image | imagine_filter('image_huge_' ~ type)) %}
{% set imgUrl_big = asset(image | imagine_filter('image_big_' ~ type)) %}
{% set imgUrl_medium = asset(image | imagine_filter('image_medium_' ~ type)) %}
{% set imgUrl_small = asset(image | imagine_filter('image_small_' ~ type)) %}
{% set imgUrl_huge = asset(image | imagine_filter('image_huge_' ~ type), 'media') %}
{% set imgUrl_big = asset(image | imagine_filter('image_big_' ~ type), 'media') %}
{% set imgUrl_medium = asset(image | imagine_filter('image_medium_' ~ type), 'media') %}
{% set imgUrl_small = asset(image | imagine_filter('image_small_' ~ type), 'media') %}
{% set srcSet = imgUrl_small ~ ' 400w,' ~ imgUrl_medium ~ ' 600w,' ~ imgUrl_big ~ ' 1200w,' ~ imgUrl_huge ~ ' 2400w'%}

<img class="video-pp__link__img" srcset="{{ srcSet }}"{% if altText %} sizes="100vw" alt="{{ altText }}"{% endif %}/>
Expand All @@ -27,7 +27,7 @@
{% set videoImage = asset('frontend/img/general/video-pp--default.svg') %}
{% set imageType = 'jpg' %}
{% if resource.thumbnail is not empty %}
{% set videoImage = asset(resource.thumbnail.url|imagine_filter('optim')) %}
{% set videoImage = asset(resource.thumbnail.url|imagine_filter('optim'), 'media') %}
{% set imageType = resource.thumbnail.originalFilename|lower|split('.')|last %}
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
{% elseif key == 'link' %}
<a href="{{ "{{ resource." ~ fieldArray['url']['fieldName'] ~ "|replace_url }}" }}" {{ "{% if resource." ~ fieldArray['new_window']['fieldName'] ~ " %}target=\"_blank\"{% endif %}" }}>{{ "{{ resource." ~ fieldArray['text']['fieldName'] ~ " }}" }}</a>
{% elseif key == 'image' %}
{{ "{% if resource." ~ fieldArray['image']['fieldName'] ~ " is not empty %}" }}<img src="{{ "{{ asset(resource." ~ fieldArray['image']['fieldName'] ~ ".url) }}" }}" {{ "{% if resource." ~ fieldArray['alt_text']['fieldName'] ~ " is not empty %}" }}alt="{{ "{{ resource." ~ fieldArray['alt_text']['fieldName'] ~ " }}" }}"{{ "{% endif %}" }} />{{ "{% endif %}" }}
{{ "{% if resource." ~ fieldArray['image']['fieldName'] ~ " is not empty %}" }}<img src="{{ "{{ asset(resource." ~ fieldArray['image']['fieldName'] ~ ".url, 'media') }}" }}" {{ "{% if resource." ~ fieldArray['alt_text']['fieldName'] ~ " is not empty %}" }}alt="{{ "{{ resource." ~ fieldArray['alt_text']['fieldName'] ~ " }}" }}"{{ "{% endif %}" }} />{{ "{% endif %}" }}
{% elseif key == 'media' %}
{{ "{% if resource." ~ fieldArray[0]['fieldName'] ~ " is not empty %}" }}<a href="{{ "{{ asset(resource." ~ fieldArray[0]['fieldName'] ~ ".url) }}" }}">{{ "{{ resource." ~ fieldArray[0]['fieldName'] ~ ".name }}" }}</a>{{ "{% endif %}" }}
{{ "{% if resource." ~ fieldArray[0]['fieldName'] ~ " is not empty %}" }}<a href="{{ "{{ asset(resource." ~ fieldArray[0]['fieldName'] ~ ".url, 'media') }}" }}">{{ "{{ resource." ~ fieldArray[0]['fieldName'] ~ ".name }}" }}</a>{{ "{% endif %}" }}
{% elseif key == 'single_ref' %}
{{ "{% if resource." ~ fieldArray[0]['fieldName'] ~ " is not empty %}" }}<div>{{ fieldArray[0]['targetEntity'] }}: {{ "{{ resource." ~ fieldArray[0]['fieldName'] ~ " }}" }}</div>{{ "{% endif %}" }}
{% elseif key == 'multi_ref' %}
Expand All @@ -30,4 +30,4 @@
<div>{{ "{% if resource." ~ fieldArray[0]['fieldName'] ~ " %}{{ resource." ~ fieldArray[0]['fieldName'] ~ "|date(\"Y-m-d H:i:s\") }}{% endif %}" }}</div>
{% endif %}
{% endfor %}{% endfor %}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ public function prepend(ContainerBuilder $container)

$container->prependExtensionConfig('doctrine', $doctrineGedmoEntityConfig);

$frameworkExtensionConfig = [
'assets' => [
'packages' => [
'media' => null,
],
],
];
$container->prependExtensionConfig('framework', $frameworkExtensionConfig);

$configs = $container->getExtensionConfig($this->getAlias());
$this->processConfiguration(new Configuration(), $configs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{% set thumbnailurl = mediaHandler.getImageUrl(item, app.request.basePath) %}

{% set cke = (app.request and app.request.get('CKEditorFuncNum')) %}
<a data-thumb-path="{{ thumbnailurl }}" data-path="{{ item.url }}" data-title="{{ item.name|escape('js') }}" data-id="{{ item.id }}" href="javascript:void(0)" class="js-url-chooser-media-select" data-cke="{% if cke %}true{% else %}false{% endif %}">
<a data-thumb-path="{{ thumbnailurl is not empty ? asset(thumbnailurl, 'media') }}" data-path="{{ asset(item.url, 'media') }}" data-title="{{ item.name|escape('js') }}" data-id="{{ item.id }}" href="javascript:void(0)" class="js-url-chooser-media-select" data-cke="{% if cke %}true{% else %}false{% endif %}">
Select
</a>
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,15 @@
{% if imageurl|lower|split('.')|last == 'svg' or 'image/svg' in media.contentType %}
{% set imageurlretina = imageurl %}
{% else %}
{% set imageurlretina = asset(imageurl | imagine_filter('media_list_thumbnail_retina')) %}
{% set imageurl = asset(imageurl | imagine_filter('media_list_thumbnail')) %}
{% set imageurlretina = asset(imageurl | imagine_filter('media_list_thumbnail_retina'), 'media') %}
{% set imageurl = asset(imageurl | imagine_filter('media_list_thumbnail'), 'media') %}
{% endif %}
{% endif %}

{% set path = "[%s]" | format("M" ~ media.id) %}

<div class="col-sm-6 col-md-4 col-lg-3">
<a href="javascript:void(0)" class="js-url-chooser-media-select thumbnail media-thumbnail" data-thumb-path="{{ imageurl }}" data-path="{{ media.url ~ '?token=' ~ path }}" data-title="{{ media.name|escape('js') }}" data-id="{{ media.id }}" data-cke="{% if cKEditorFuncNum %}true{% else %}false{% endif %}">
<a href="javascript:void(0)" class="js-url-chooser-media-select thumbnail media-thumbnail" data-thumb-path="{{ imageurl }}" data-path="{{ asset(media.url ~ '?token=' ~ path, 'media') }}" data-title="{{ media.name|escape('js') }}" data-id="{{ media.id }}" data-cke="{% if cKEditorFuncNum %}true{% else %}false{% endif %}">
<figure>
{% if imageurl %}
<img src="{{ imageurl }}" srcset="{{ imageurl }} 1x, {{ imageurlretina is defined ? ', ' ~ imageurlretina ~ " 2x" }}" alt="{{ media.name }}" class="media-thumbnail__img">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@
{% if imageurl|lower|split('.')|last == 'svg' or 'image/svg' in media.contentType %}
{% set imageurlretina = imageurl %}
{% else %}
{% set imageurlretina = asset(imageurl | imagine_filter('media_list_thumbnail_retina')) %}
{% set imageurl = asset(imageurl | imagine_filter('media_list_thumbnail')) %}
{% set imageurlretina = asset(imageurl | imagine_filter('media_list_thumbnail_retina'), 'media') %}
{% set imageurl = asset(imageurl | imagine_filter('media_list_thumbnail'), 'media') %}
{% endif %}
{% endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
{% if imageurl|lower|split('.')|last == 'svg' or 'image/svg' in media.contentType %}
{% set imageurlretina = imageurl %}
{% else %}
{% set imageurlretina = asset(imageurl | imagine_filter('media_list_thumbnail_retina')) %}
{% set imageurl = asset(imageurl | imagine_filter('media_list_thumbnail')) %}
{% set imageurlretina = asset(imageurl | imagine_filter('media_list_thumbnail_retina'), 'media') %}
{% set imageurl = asset(imageurl | imagine_filter('media_list_thumbnail'), 'media') %}
{% endif %}
{% endif %}
{% if imageurl %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends '@KunstmaanMedia/Media/show.html.twig' %}

{% block extraactions %}
<a href="{{ asset(media.url) }}" target="_blank" class="btn btn-primary btn--raise-on-hover">
<a href="{{ asset(media.url, 'media') }}" target="_blank" class="btn btn-primary btn--raise-on-hover">
{{ 'media.media.download.action'|trans }}
</a>
{% endblock %}
Expand All @@ -14,9 +14,9 @@
{{ 'media.media.mediainfo.downloadlink'|trans }}:
</dt>
<dd>
{% set mediaUrl = media.url %}
<a href="{{ absolute_url(asset(mediaUrl)) }}" target="_blank">
{{ absolute_url(asset(mediaUrl)) }}
{% set mediaUrl = absolute_url(asset(media.url, 'media')) %}
<a href="{{ mediaUrl }}" target="_blank">
{{ mediaUrl }}
</a>
</dd>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
{% block extraactions %}

{% if handler.aviaryApiKey and not (handler.aviaryApiKey starts with 'Register') %}
<button type="button" class="btn btn-primary btn--raise-on-hover" onclick="return launchEditor('editimage', '{{ absolute_url(asset(media.url)) }}');" >
<button type="button" class="btn btn-primary btn--raise-on-hover" onclick="return launchEditor('editimage', '{{ absolute_url(asset(media.url, 'media')) }}');" >
{{ 'media.media.edit.action' | trans }}
</button>

{% include '@KunstmaanMedia/Media/Image/aviary.html.twig' %}
{% endif %}

<a href="{{ asset(media.url) }}" target="_blank" class="btn btn-default btn--raise-on-hover">
<a href="{{ asset(media.url, 'media') }}" target="_blank" class="btn btn-default btn--raise-on-hover">
{{ 'media.media.download.action'|trans }}
</a>
{% endblock %}
Expand All @@ -21,7 +21,7 @@
{% if imageurl|lower|split('.')|last == 'svg' or 'image/svg' in media.contentType %}
{% set imageurl = imageurl %}
{% else %}
{% set imageurl = asset(imageurl | imagine_filter('media_detail_thumbnail')) %}
{% set imageurl = asset(imageurl | imagine_filter('media_detail_thumbnail'), 'media') %}
{% endif %}
{% endif %}
<img id="editimage" class="img-thumbnail" src="{{ imageurl }}" alt="{{ media.name }}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
{% if name is empty %}
{% set name = "Download" %}
{% endif %}
<p class="download-pp"><a href="{{ absolute_url(asset(resource.media.url)) }}" target="_blank" class="download">{{ name }}</a> <span>| {{ resource.media.contentTypeShort }} {{ resource.media.getFileSize() }}</span></p>
<p class="download-pp"><a href="{{ absolute_url(asset(resource.media.url, 'media')) }}" target="_blank" class="download">{{ name }}</a> <span>| {{ resource.media.contentTypeShort }} {{ resource.media.getFileSize() }}</span></p>
{% endif %}

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="image-pp">
{% set imgUrl = '' %}
{% if app.request %}
{% set imgUrl = absolute_url(asset(resource.media.url)) %}
{% set imgUrl = absolute_url(asset(resource.media.url, 'media')) %}
{% endif %}
{% if resource.link is defined and resource.link != "" %}
<a href="{{ resource.link | replace_url}}" {% if resource.openinnewwindow %}target="_blank"{% endif %}><img src="{{ imgUrl }}" alt="{{ resource.alttext }}" /></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{% for pagePartType in pagepartadmin.possiblePagePartTypes %}
<div class="pp-search__item js-pp-search-item col-sm-6 col-lg-4" data-pp-name="{{ pagePartType.name|trans }}">
{% if pagePartType.preview is defined and pagePartType.preview is not empty %}
{% set background = asset(pagePartType.preview) %}
{% set background = asset(pagePartType.preview, 'media') %}
{% else %}
{% set background = asset('bundles/kunstmaanadmin/default-theme/img/kunstmaan/ppchooser-placeholder.svg') %}
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@
{% else %}
{% set imageUrl = seo.getOgImage().getUrl() | imagine_filter('fb_og_image') %}
{% set dimensions = get_image_dimensions(imageUrl) %}
<meta property="og:image" content="{{ asset(imageUrl) }}">
<meta property="og:image" content="{{ asset(imageUrl, 'media') }}">
<meta property="og:image:type" content="{{ seo.ogImage.contentType }}">
{% if dimensions %}
<meta property="og:image:height" content="{{ dimensions.height }}">
<meta property="og:image:width" content="{{ dimensions.width }}">
{% endif %}
<link rel="image_src" href="{{ asset(imageUrl) }}"/>
<link rel="image_src" href="{{ asset(imageUrl, 'media') }}"/>
{% endif %}
{% endif %}

Expand Down Expand Up @@ -102,9 +102,9 @@
<meta name="twitter:player" content="{{ videoUrl }}" />
<meta name="twitter:player:width" content="960">
<meta name="twitter:player:height" content="540">
<meta name="twitter:image:src" content="{{ absolute_url(asset(seo.twitterImage.metaData.thumbnail_url)) }}" />
<meta name="twitter:image:src" content="{{ absolute_url(asset(seo.twitterImage.metaData.thumbnail_url, 'media')) }}" />
{% else %}
<meta name="twitter:image:src" content="{{ asset(seo.twitterImage.url | imagine_filter('tw_card_image')) }}" />
<meta name="twitter:image:src" content="{{ asset(seo.twitterImage.url | imagine_filter('tw_card_image'), 'media') }}" />
{% endif %}
{% endif %}
{% endif %}
Expand Down

0 comments on commit 19fc3c4

Please sign in to comment.