templates/blocks/_open_graph.html.twig line 1

Open in your IDE?
  1. <!-- OPEN GRAPH BEGINNING -->
  2. {% if post.imageSocialMedia is defined and post.imageSocialMedia is not null and post.imageSocialMedia|length > 0 %}
  3.     {% set image_social_media = post.imageSocialMedia %}
  4. {% else %}
  5.     {% if letstalkType == 'site' %}
  6.         {% set image_social_media = 'defaut-site.webp' %}
  7.     {% elseif letstalkType == 'seo' %}
  8.         {% set image_social_media = 'defaut-seo.webp' %}
  9.     {% else %}
  10.         {% set randomType = random(['site', 'seo']) %}
  11.         {% set image_social_media = 'defaut-' ~ randomType ~ '.webp' %}
  12.     {% endif %}
  13. {% endif %}
  14. {% set currentRoute = app.request.attributes.get('_route') %}
  15. {% set og_type = currentRoute == 'show_post' ? 'article' : 'website'  %}
  16. {% set image_social_media_height = currentRoute == 'show_post' ? '630' : '1200'  %}
  17. <meta property="og:locale" content="fr_FR">
  18. <meta property="og:title" content="{{ title_tag }}"/>
  19. <meta property="og:type" content="{{og_type}}"/>
  20. <meta property="og:description" content="{{ description_tag}}"/>
  21. <meta property="og:url" content="{{canonical_url}}">
  22. <meta property="og:site_name" content="Refined web">
  23. <meta property="og:image" content="{% block og_image %}{{ absolute_url(asset('images/social-medias/' ~ image_social_media)) }}{% endblock %}">
  24. <meta property="og:image:width" content="1200">
  25. <meta property="og:image:height" content="{{image_social_media_height}}">
  26. {% if og_type == 'article'%}
  27.     {% if post.publishedOn is defined and post.publishedOn|date('c') is not null %}
  28.         <meta property="og:article:published_time" content="{{post.publishedOn|date('c')}}">
  29.         <meta property="og:article:modified_time" content="{{post.updatedAt|date('c')}}">
  30.         <meta property="og:updated_time" content="{{post.updatedAt|date('c')}}">
  31.     {% endif %}
  32.     {% if post.author.name is defined and post.author.name is not null %}
  33.         <meta property="og:article:author" content="{{post.author.name}}">
  34.     {% endif %}
  35.     {% if post.blogHome.title is defined and post.blogHome.title is not null %}
  36.         <meta property="og:article:section" content="{{post.blogHome.title}}">
  37.     {% endif %}
  38. {% endif %}
  39. <meta name="twitter:card" content="summary_large_image">
  40. <meta name="twitter:creator" content="@refinedwebfr">
  41. <meta name="twitter:site" content="@refinedwebfr">
  42. <meta name="twitter:image" content="{{ block('og_image') }}">
  43. <!-- <meta property="fb:app_id" content=""> -->
  44. <!-- OPEN GRAPH END -->