Media Links

Hello,

I’ve just started using Grav and I’m using it to build a portfolio site at the moment. I’m having an issue with displaying the media related to a page - particularly in my local environment because the paths are coming out incorrectly. I used the short tutorial here as a base for this part: http://learn.getgrav.org/cookbook/general-recipes#creating-a-simple-gallery

My git repo is here: https://github.com/ChrisSargent/moodesignz

I guess the file that is generating this is in user/themes/moo/templates/portfolio.html.twig

If you could point me in the right direction, it would be much appreciated…

Thanks,

Chris

in order to make use of the template portfolio.html.twig, your markdown file name should be the same,ie portfolio.md and located in the same folder as your images.

Hi Hugo,

Thanks for that - I am actually using Yaml front matter to define the template to use (I’m not a fan of the naming convention). In either case, the templating part is fine, it’s just the path that’s being generated to the images that isn’t working correctly.

Chris

What is wrong with the paths generated? Can you provide a sample of the output your getting?

So it’s just adding in a far too deep path for some reason - I’m not sure where or how this is controlled.

hmm. ok that’s weird, it’s actually linking to the image filesystem path, and not the image URL.

What is the Twig you have to output the image? Please paste between triple back ticks so it formats the code properly (click ? in top right corner of input box for help)

Here you go…

    {% for image in page.media.images %}
    <li>
        <div>
            {{ image.html() }}
        </div>
    </li>
    {% endfor %}
</ul>

Taken from the cookbook: http://learn.getgrav.org/cookbook/general-recipes#creating-a-simple-gallery

Could it be something my server config is doing? I’m just using this command to serve the site

$ php -S localhost:8000

I’m just going to remove the reference to using the built in web server because while most of Grav works fine with it, it does break when it comes to routing. It could be the cause of your problems.

Try using a proper LAMP stack.

Hi… Okay, had a bit of a clean out of things on my Mac and then reinstalled a MAMP stack using Homebrew, following this guide: https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew

It all seems to be working now, thanks.

LOL you used that guide, but you should of used the one I wrote :slight_smile: http://getgrav.org/blog/mac-os-x-apache-setup-multiple-php-versions