nhoizey/jekyll-cloudinary

Support images defined in Front Matter

nhoizey opened this issue · 2 comments

From a comment by @judsonlmoore in #51 :
#51 (comment)

Hi @judsonlmoore ,

I'm very sorry for the late answer. I don't use Jekyll anymore and have little time for my numerous pet projects like this one.

I think I have a similar issue as what is described here, so will add a comment instead of starting a new topic.

I think your issue is not related to @k16e-me 's.

He's trying to use the Liquid tag in a page, but it unfortunately works only in posts.

I've been trying to use this (awesome!) plugin to transform images in the page templates with Cloudinary. I've tried a wide array of implementation options including the below:

{% cloudinary page.image alt="{{ page.title }}" %}
{% cloudinary { page.image } alt="{{ page.title }}" %}
{% cloudinary {{ page.image }} alt="{{ page.title }}" %}

It looks like you try to use the Liquid tag with an image that you define in Front Matter, which is not supported either. But is a different feature.

Interestingly, the page.title attribute is supported and does properly print the page title into the alt tag.

I guess this is because Jekyll processes site variables (such as {{ page.* }}) before Liquid tags:
https://jekyllrb.com/tutorials/orderofinterpretation/#order-of-interpretations

However, the tag for the page.image without brackets simply inserts that text at the end of the cloudinary url with this error:

I guess then {% cloudinary {{ page.image }} … should work too, I'll have to investigate why it doesn't.

[Cloudinary] Couldn't find this image to check its width: /Users/judmoore/github/judsonlmoore.com/_posts/travel/destinations/ireland/page.imag.
Note that the "e" is missing at the end of page.image. Not sure why.

This might help me track the issue, thanks for noticing.

Questions

1. Is there a currently-supported proper way to do what I am aiming to accomplish?

I'm not sure, I'll try to fix this and document an official way.

2. Might this be supported soon?

Soon, I'm not sure, as I have to install the whole Ruby/Jekyll stuff again on a computer.

I'll do my best.

3. Any other recommendations for handling non-post-content images with cloudinary?

Did you try using absolute URLs for the image?

`{% cloudinary https://example.com/path/to/the/image.jpg alt="…" %}

By the way, it looks like @carloteran19 is using Front Matter defined images without (this) issue:
#87 (comment)

Might be worth discussing…