SVG image not being displayed for a specific product

Hi there,

I’ve an svg image that lives inside a folder (which lives inside the content folder) like this:

content/
0_stuhl-one
/stapelstuhl-icon.svg

I’ve this code but the svg image is not being displayed even though I’ve uploaded it via the Kirby panel to show for this specific product:

                <?php
$items = $stuehle->structurethree()->toStructure();

if (count($items) > 0) {
    // Check if the Stapelstuhl image is uploaded for a specific product
    $stapelstuhlImage = $items->first()->image()->toFile();

    if ($stapelstuhlImage) {
        // If the Stapelstuhl image is available, display it
        echo '<img src="' . $stapelstuhlImage->url() . '" class="stapelstuhl">';
    }
}
?>

Grateful for your guidance.

I applied the same logic to another section of the same template and it worked fine (it was a PNG image however). Here the code:

 <!-- Accordion 4 -->

                            <?php
                            $items = $stuehle->structuretwo()->toStructure();

                            if (count($items) > 0) {
                                // If items are found, display the code
                                echo '<details>
                                            <summary>
                                                <button class="accordion-button collapsed bold-accordion-header" type="button">
                                                    Stoffe
                                                </button>
                                            </summary>
                                            <div class="product-palette">';

                                foreach ($items as $item) {
                                    echo '
                                            <div class="palette-box">
                                                <div class="image-container">
                                                    <h3>' . $item->label()->html() . '</h3>
                                                    <img src="' . $item->image()->toFile()->url() . '" alt="' . $item->label()->html() . '">
                                                </div>
                                            </div>';
                                }
                                echo '</div>
                                    </details>';
                            }
                            ?>

is this condition true?

is this condition true?

1 Like

Awesome, many thanks for your guidance.