-
Notifications
You must be signed in to change notification settings - Fork 4
/
image.ejs
19 lines (19 loc) · 805 Bytes
/
image.ejs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<figure>
<picture>
<%_ for (const type of Object.keys(files).filter((f) => f !== 'default')) { _%>
<%_ const typeSizes = Object.keys(files[type]) _%>
<%_ for (const typeSize of Object.keys(files[type])) { _%>
<%_ const url = files[type][typeSize] _%>
<%_ const mimeType = `image/${type}` _%>
<%_ const { media } = dimensions[typeSize] _%>
<source srcset="<%= url %>"<%- media ? `media="${media}" ` : '' %> type="<%= mimeType %>" />
<%_ } _%>
<%_ } _%>
<%_ if (files.default) { _%>
<img src="<%= files.default %>" alt="<%= alt %>" />
<%_ } _%>
</picture>
<%_ if (caption) { _%>
<figcaption><%= caption %></figcaption>
<%_ } _%>
</figure>