#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