3

I have an entry with one asset field and i need to determine if the 'kind' of asset is either 'json' file or 'video' file. Basically I swap my HTML based on the return 'kind'.

Any help is greatly appreciated. Craft CMS beginner.

{% set videoEntries =  craft.entries({ section: 'mediaRoomVideos' }).find %}
{% if videoEntries is not empty %}

    {% for entry in videoEntries %}
        {% set asset = entry.mediaVideo.first() %}

        {% if asset %}

            {% set json = asset.kind('json') %}
                {% if json %}
                    Do Embedded Video
                {% else %}

                    <video width="320" height="240" controls>
                        <source src="{{ entry.mediaVideo.first.getUrl() }}">
                    </video>

                {% endif %}
        {% endif %}
    {% endfor %}
{% endif %}

1 Answer 1

4
{% if json %}

Replaced with.

{% if asset.kind == 'json' %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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