#ThumbnailPlugin How do I use meta-data while using the thumbnail-plugin?

StackOverflow https://stackoverflow.com/questions/19811311

  •  04-07-2022
  •  | 
  •  

سؤال

When I use images from metadata in my layouts, I do it like this and it works:

    <img src="<%= @site.url %>/images/<%= @document.icon %>" alt="" title="">

When I use the wonderful working thumbnail-plugin for DocPad like this, it works well, too:

<img src="<%= @getThumbnail("images/javascript.png", '128x128') %>" alt="">

Now I would like to combine both methods, to get the metadata from the document and let the thumbnail-plugin size it like I want. Is this possible? I tried something like this:

<img src="<%= @getThumbnail("images/<%= @document.icon %>", '128x128') %>" alt="">

I know the code above is crap, I am sorry... Just to explain what I would like to do.

هل كانت مفيدة؟

المحلول

You can definitely do what you're wanting to do. The key point to realize is probably that when using eco, <%= puts you in 'coffeescript' mode and you can write any coffescript expression you want.

So to do what you want, you'd write this markup:

<img src="<%= @getThumbnail('images/' + @document.icon, '128x128') %>" alt="">
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top