szurubooru/public_html/templates/post-content.tpl

62 lines
2 KiB
Smarty
Raw Normal View History

2015-03-13 20:56:12 +01:00
<%
2015-06-28 12:25:35 +02:00
var postContentUrl = '/data/posts/' + post.name + '?' + Math.round(Math.random() * 1000) /* reset gif animations */
var width;
var height;
if (post.contentType === 'image' || post.contentType === 'animation' || post.contentType === 'flash') {
width = post.imageWidth;
height = post.imageHeight;
} else {
width = 800;
height = 600;
}
2015-03-13 20:56:12 +01:00
%>
2014-09-21 10:56:37 +02:00
<div class="post-content post-type-<%= post.contentType %>">
2015-06-28 12:25:35 +02:00
<div class="post-notes-target">
</div>
2014-09-21 10:56:37 +02:00
2015-06-28 12:25:35 +02:00
<div
class="object-wrapper"
data-width="<%= width %>"
data-height="<%= height %>"
style="max-width: <%= width %>px">
2015-03-13 20:56:12 +01:00
2015-06-28 12:25:35 +02:00
<% if (post.contentType === 'image' || post.contentType === 'animation') { %>
2014-09-21 10:56:37 +02:00
2015-06-28 12:25:35 +02:00
<img alt="<%= post.name %>" src="<%= postContentUrl %>"/>
2014-09-21 10:56:37 +02:00
2015-06-28 12:25:35 +02:00
<% } else if (post.contentType === 'youtube') { %>
2014-09-21 10:56:37 +02:00
2015-06-28 12:25:35 +02:00
<iframe src="//www.youtube.com/embed/<%= post.contentChecksum %>?wmode=opaque" allowfullscreen></iframe>
2014-09-21 10:56:37 +02:00
2015-06-28 12:25:35 +02:00
<% } else if (post.contentType === 'flash') { %>
2014-09-21 10:56:37 +02:00
2015-06-28 12:25:35 +02:00
<object
type="<%= post.contentMimeType %>"
width="<%= width %>"
height="<%= height %>"
data="<%= postContentUrl %>">
<param name="wmode" value="opaque"/>
<param name="movie" value="<%= postContentUrl %>"/>
</object>
2014-09-21 10:56:37 +02:00
2015-06-28 12:25:35 +02:00
<% } else if (post.contentType === 'video') { %>
2014-09-21 10:56:37 +02:00
2015-06-28 12:25:35 +02:00
<% if (post.flags.loop) { %>
<video id="video" controls loop="loop">
<% } else { %>
<video id="video" controls>
<% } %>
2014-09-21 10:56:37 +02:00
2015-06-28 12:25:35 +02:00
<source type="<%= post.contentMimeType %>" src="<%= postContentUrl %>"/>
2015-06-28 12:25:35 +02:00
Your browser doesn't support HTML5 videos.
</video>
2014-09-21 10:56:37 +02:00
2015-06-28 12:25:35 +02:00
<% } else { console.log(new Error('Unknown post type')) } %>
2015-03-13 20:56:12 +01:00
2015-06-28 12:25:35 +02:00
<div class="padding-fix" style="padding-bottom: calc(100% * <%= height %> / <%= width %>)"></div>
</div>
2014-09-21 10:56:37 +02:00
</div>