Hi, but if i would want a different image in item? Because in the blog post in the page of the blog there is the image put in the same folder but i would want display a different image or nothing in the header of article…how can i do it? Sorry for mistakes…english isn’t my language…
Hi, thank you for your answer. My theme is Antimatter, and i want to change the header image of the article, the item page that now is the same of the preview post in the blog post. When I put the first image, it set both the blog post summary and in the header of blog item. I don’t want the same image…
@semplicewebsite Would you like to show different images for the blog item in the list ('blog.html.twig') and on the blog item itself ('item.html.twig')?
Unfortunately that option is not build in… Both pages use 'partials/blog_item.html.twig' to display the blog item.
Create a child theme using $ bin/plugin devtools newtheme. In the wizard choose ‘inheritance’ and ‘antimatter’
Copy 'partials/blog_item.html.twig' from Antimatter to same folder in your new theme.
In 'user/themes/<your theme>/blueprints/item.yaml' duplicate the fields named ‘header.header_image’ and ‘header.header_image_file’ and append ‘_list’ to the names.
Now your can add image properties specific for items in the list.
In 'user/themes/<your theme>/templates/partials/blog_item.html.twig':
Remove the following statements at the top of the template.
{% set header_image = page.header.header_image|defined(true) %}
{% set header_image_file = page.header.header_image_file %}
Create an if-statement right above the part that displays the header, like:
{# Note: truncate is set in template `'blog.html.twig'` and passed to `'partials/blog_item.html.twig'` #}
{% if truncate %}
{% set header_image = page.header.header_image_list|defined(true) %}
{% set header_image_file = page.header.header_image_file_list %}
{% else %}
{% set header_image = page.header.header_image|defined(true) %}
{% set header_image_file = page.header.header_image_file %}
{% endif %}
My script presumed a Unix OS. Have you considered to set up Windows Subsystem for Linux? I’m running Windows 10 and moved all my development to WSL and love it.
You can replace step 1. by creating a child theme manually. Follow steps 1-5 from the docs Theme Inheritance.
Please don’t hesitate to ask for further assistance if you get stuck.