Text as watermark in front-end
Created 6 years ago by pwrobel

I need to add text as watermark to every image in gallery on page. I display gallery through page types, so I need a twig solution. I didnt find it in docs. Intervention library has o text method but i cant use it in twig. Is there any simple way to do this?

edster  —  6 years ago

Check the files documentation. My guess is the method hasn't been enabled by Ryan at all, which is why you can't use it in twig.

To get it fixed make an issue on GitHub.

ryanthompson  —  6 years ago

Image plugin / class in Pyro wraps Intervention and that method should be allowed. Something like this I imagine:

{{ image('theme::img/my-image.jpg').insert(image_path('theme::another/image.jpg'), bottom-right, 10, 10)|raw }}

http://image.intervention.io/api/insert

pwrobel  —  6 years ago

Yup, there is no problem with insert image as watermark. Problem is that I need insert text as watermark. I tried to use {{ image('path').text(' my text).url() }} (intervention has text method) but it didnt work for me. I think insert method shouldn't work too in this case.

ryanthompson  —  6 years ago

Aha! Good call - I've added it to the allowed methods: https://github.com/anomalylabs/streams-platform/commit/60393bc4f46a7c51cbd2ae675c08983f5aae3242

Let me know how this works!

pwrobel  —  6 years ago

I tried that solution before, but it didnt work for me.

{% for photo in page.aups %}
        {{ image(photo).fit(900,1500).text('some text', 10, 10)|raw }}
{% endfor %}

I tried do it that way. Inserting images works perfectly but I cant find solution for that 🙍.

ryanthompson  —  6 years ago

Bah looks like they're working but I need to map the closure options to an array of config for the plugin use:

See my pathetic example / output lol: https://image.prntscr.com/image/ead0d1e21f494f63a64f0ac0a03cb94c.png

That's at like 300% zoom

I'll get this knocked out and let you know.

pwrobel  —  6 years ago

Ok, thanks for help Ryan!