Is there a way to use a switch statement on redactors output i.e. to say -
If this output is a video > use this code
if this output is a Image > use this code
Why? Well i'm trying to apply imager (to reduce image sizes) to the images that are being added into redactor.
Little more detail:
So currently I run a loop of all the redactor inputs
{% for i in block.questionBlock.all() %}
<article>
<div class="text">
{{ i.answer }}
</div>
<div class="media">
{{ i.media }}
</div>
</article>
{% endfor %}
In the block {{ i.media }}
I need to get into this block to check its contents and see if it is an image and if it is to apply imager to it. I figured that a switch statement would work best, but I am unsure how to check what the content of {{ i.media }}
.
I know that the picture will have a img
html tag and the video with have a iframe
tag - so is there a way to say.
if i.media contains img
Any ideas?
Thanks - W