Twig RuntimeError in hero-blog component when blog post has no featured image
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3583766. -->
Reported by: [kruser](https://www.drupal.org/user/383124)
Related to !32
>>>
<h3>Problem/Motivation</h3>
<p>When viewing a blog node (<code>node.blog.full</code>) that does not have a value in <code>field_featured_image</code>, the page crashes with a Twig RuntimeError.</p>
<h4>Full error</h4>
<pre><pre>Twig\Error\RuntimeError occurred during rendering of component<br>14f8bf3e-e882-48fb-ba4e-83e932f0748b in Content template<br>Blog post content items — Full content view (node.blog.full):<br>An exception has been thrown during the rendering of a template<br>("[canvas:image/src] NULL value found, but a string or an object is required...<br>[canvas:image/alt] NULL value found, but a string or an object is required...<br>[canvas:image/width] NULL value found, but an integer or an object is required.<br>[canvas:image/height] NULL value found, but an integer or an object is required.")<br>in "canvas:image" at line 1.</pre></pre><h4>Root cause</h4>
<p>The issue is in <code>components/hero-blog/hero-blog.twig</code>. The template unconditionally includes the <code>canvas:image</code> component, passing <code>media.src</code>, <code>media.alt</code>, <code>media.width</code>, and <code>media.height</code>. When the blog node has no featured image, these values are NULL, and the <code>canvas:image</code> component's typed props reject NULL, causing the Twig render error.</p>
<h3>Steps to reproduce</h3>
<ol>
<li>Install Drupal CMS 2.0.x with the default Canvas content templates.</li>
<li>Create a new Blog post.</li>
<li>Fill in only the Title and Description (leave "Featured image" empty).</li>
<li>Save and view the blog post.</li>
<li>Observe the Twig RuntimeError.</li>
</ol>
<h3>Proposed resolution</h3>
<p>Guard the <code>canvas:image</code> include with an <code>{% if media.src %}</code> check so the image only renders when a featured image is set. Also add <code>|default('')</code> on <code>alt</code> as a safety net.</p>
<h3>Remaining tasks</h3>
<ul>
<li>Review patch</li>
<li>Commit</li>
</ul>
<h3>User interface changes</h3>
<p>None when a featured image is present. When no featured image is set, the hero area renders without an image instead of crashing.</p>
<h3>API changes</h3>
<p>None.</p>
<h3>Data model changes</h3>
<p>None.</p>
issue