0

Hope I'm not posting incorrectly here but don't have enough reputation yet (really don't understand that system at all) to be able to comment on another post here on the exchange.

Original Post - inline image transforms

I'd like to get this to work but not having any luck at all. This is my code in my template so far.

{% for block in entry.matrixBlocks %}

    {% if block.type == "text" %}

    <p>{{ block.text }}</p>

    {% elseif block.type == "quote" %}

    <blockquote class="{{ block.floatPosition }}">
    <p>{{ block.quote }}</p>
    </blockquote>

    {% elseif block.type == "image" %}

    {% set smallImage
        = {
        mode: 'fit',
        width: 600,
        height: 200,
        quality: {{ block.quality.value }},
        position: 'top-center'
        }
    %}

    {% for asset in block.image %}
    <img src="{{ asset.getUrl(smallImage) }}"
    width="{{ asset.getWidth(smallImage) }}"
    height="{{ asset.getHeight(smallImage) }}">
    {% endfor %}
    {% endif %}

{% endfor %}

The quality in {{ block.quality.value }} is the name (handle) of a field I have storing a number from 1-100 in my Matrix Block. I am using Max Lazars range field to store the number.

Upon trying this say by Live Preview the page never refreshes. If I change the {{ block.quality.value }} to a number then it all works again as expected.

Would love to get this working so any help would be greatly appreciated to let me know where I'm going wrong.

Thanks,

Mark

  • Aha!!! Got it working at last!! As I was using Live Preview, even though I was set to Dev Mode for any errors, they weren't showing in the Live Preview pane (maybe that should be a feature request?). As soon as I tested it out on the live page I saw an error and it told me to place parentheses around an expression so I did this instead quality: (block.quality.value) and all is good with the world now!! :-) – Mark Bowen May 13 '15 at 22:50
1

Aha!!! Got it working at last!!

As I was using Live Preview, even though I was set to Dev Mode for any errors, they weren't showing in the Live Preview pane (maybe that should be a feature request?).

As soon as I tested it out on the live page I saw an error and it told me to place parentheses around an expression so I did this instead :

quality: (block.quality.value) and all is good with the world now!! :-)

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.