Cover images are not loading on server but in localhost

hey folks,

I stumbled over a weird issue with looping over some cover images.

My site has a portfolio page, which gives an overview over some projects. In each project subpage is a cover image. In the portfolio page I just loop over the cover images and link to their specific project page.

The images are showing up in localhost, but not on the actual server. In the dev tools the <a> tag has the correct link to the subpage, but the images are not showing up.
I have to say, that I do not have a lot of experience. Not yet :sweat_smile: Is it some problem with my Code?

my code from the portfolio page:

<div class="portfolio-image">
    <?php foreach($page->children() as $subpage): ?>

        <a class="element" href="<?= $subpage->url() ?>">
            <?php if ($cover = $subpage->cover()->resize(2500, 1050)->toFile()): ?>
            <img src="<?= $cover->url() ?>" alt="<?= $cover->alt() ?>" />
            <span><?= $subpage->title()->html() ?></span>
            <?php endif ?>

    <?php endforeach ?>

my project subpage blueprint:

title: Dienstleistung

    width: 2/3
        type: fields
            type: files
            template: image
            label: Intro Überschrift
            type: text 

-Im using mamp as local environment
-My site is in a subfolder on the server, so i changed the .htaccess rewritebase to the subfolder
-I don’t get any error messages

Im grateful for every tip. Thanks

Your code is not correct, should be

<?php if ($cover = $subpage->cover()->toFile()): ?>
    <img src="<?= $cover->resize(2500, 1050)->url() ?>" alt="<?= $cover->alt() ?>" />
    <span><?= $subpage->title()->html() ?></span>
<?php endif ?>
1 Like

Sorry, I missed that. Thanks you so much. Everything is working fine now. You made my day.