1

As of right now I have nine or so structures created, each including it's own Image Gallery created in a Matrix.

Is it possible to give each image inside that matrix a unique URL?

What I'm trying to accomplish is to be able to create multiple galleries, each gallery when clicked will just pull up into a Fancybox. The problem with this, is there also needs to be social media sharing (Facebook, Twitter, Pinterest, and Google+) for each item in the gallery. After a bit of research the Facebook og:image tag only shares what is in that URL being shared. So I will need to be able to create pages for each item in the gallery. Would this be possible?

3

You can do this by creating a "single image" template, and point to that template with a URL GET variable containing the Asset ID, for example:

http://yoursite.com/gallery/single?assetId=234

First, create a template for your "single" image – e.g /templates/gallery/single.twig (I like to use the twig extension rather than .html, but its not important).

Add the following Twig code to your template – it will look at the current request query string for the assetId variable, and try to pull the relevant Asset:

{% set assetId = craft.request.getParam( 'assetId' ) %}
{% if assetId %}
{% set asset = craft.assets.id( assetId ).first() %}
{% endif %}

Then, you can easily output the image in whatever way you want, here's an example:

{% extends 'layouts/myGalleryTemplate' %}
{% block single %}
    {% if asset is defined %}
        <img src="{{ asset.getUrl() }}" width="{{ asset.getWidth() }}" height="{{ asset.getHeight() }}" alt="" />
    {% else %}
        <p class="error">The specified image could not be found</p>
    {% endif %}
{% endblock %}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.