play inline video
This commit is contained in:
parent
51eff7f9b5
commit
87d1bee1df
2
camp/static/css/foundation.css
vendored
2
camp/static/css/foundation.css
vendored
|
@ -447,7 +447,7 @@ body {
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale; }
|
-moz-osx-font-smoothing: grayscale; }
|
||||||
|
|
||||||
img {
|
img, video.gif {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
|
|
@ -169,6 +169,35 @@ class Content(models.Model):
|
||||||
values = [
|
values = [
|
||||||
('og:title', self.title),
|
('og:title', self.title),
|
||||||
]
|
]
|
||||||
|
video_url = self.video_url
|
||||||
|
if video_url:
|
||||||
|
video_path = self.photo.image.path.replace('.gif', '.mp4')
|
||||||
|
image_path = self.photo.image.path.replace('.gif', '.jpg')
|
||||||
|
if os.path.exists(video_path):
|
||||||
|
if video_url.startswith('/'):
|
||||||
|
video_url = 'https://studio.camp' + video_url
|
||||||
|
image_url = video_url.replace('.mp4', '.jpg')
|
||||||
|
width = self.photo.image.width
|
||||||
|
height = self.photo.image.height
|
||||||
|
values = [
|
||||||
|
('og:video', video_url),
|
||||||
|
('og:video:type', "video/mp4"),
|
||||||
|
('og:video:width', str(width)),
|
||||||
|
('og:video:height', str(height)),
|
||||||
|
('og:image', image_url),
|
||||||
|
] + values
|
||||||
|
else:
|
||||||
|
values += [
|
||||||
|
('og:image', 'https://studio.camp%s' % self.image_url),
|
||||||
|
]
|
||||||
|
for key, value in values:
|
||||||
|
headers.append(
|
||||||
|
'<meta property="%s" content="%s"/>' % (html.escape(key, True), html.escape(value, True))
|
||||||
|
)
|
||||||
|
return mark_safe("\n".join(headers))
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def video_url(self):
|
||||||
if self.photo and self.photo.image.url.endswith('.gif'):
|
if self.photo and self.photo.image.url.endswith('.gif'):
|
||||||
video_path = self.photo.image.path.replace('.gif', '.mp4')
|
video_path = self.photo.image.path.replace('.gif', '.mp4')
|
||||||
image_path = self.photo.image.path.replace('.gif', '.jpg')
|
image_path = self.photo.image.path.replace('.gif', '.jpg')
|
||||||
|
@ -186,30 +215,7 @@ class Content(models.Model):
|
||||||
'-i', self.photo.image.path, '-frames:v', '1', image_path
|
'-i', self.photo.image.path, '-frames:v', '1', image_path
|
||||||
]
|
]
|
||||||
subprocess.call(cmd)
|
subprocess.call(cmd)
|
||||||
if os.path.exists(video_path):
|
return video_url
|
||||||
video_url = self.photo.image.url.replace('.gif', '.mp4')
|
|
||||||
if video_url.startswith('/'):
|
|
||||||
video_url = 'https://studio.camp' + video_url
|
|
||||||
image_url = video_url.replace('.mp4', '.jpg')
|
|
||||||
width = self.photo.image.width
|
|
||||||
height = self.photo.image.height
|
|
||||||
values = [
|
|
||||||
('og:video', video_url),
|
|
||||||
('og:video:type', "video/mp4"),
|
|
||||||
('og:video:width', str(width)),
|
|
||||||
('og:video:height', str(height)),
|
|
||||||
('og:image', image_url),
|
|
||||||
] + values
|
|
||||||
else:
|
|
||||||
values += [
|
|
||||||
('og:image', 'https://studio.camp%s' % self.image_url),
|
|
||||||
]
|
|
||||||
|
|
||||||
for key, value in values:
|
|
||||||
headers.append(
|
|
||||||
'<meta property="%s" content="%s"/>' % (html.escape(key, True), html.escape(value, True))
|
|
||||||
)
|
|
||||||
return mark_safe("\n".join(headers))
|
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def image_url(self):
|
def image_url(self):
|
||||||
|
|
|
@ -6,7 +6,9 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% include "edit.html" %}
|
{% include "edit.html" %}
|
||||||
<div class="large-8 medium-8 columns special-column">
|
<div class="large-8 medium-8 columns special-column">
|
||||||
{% if content.image_url %}
|
{% if content.video_url %}
|
||||||
|
<video class="gif" autoplay loop src="{{ content.video_url }}"></video>
|
||||||
|
{% else content.image_url %}
|
||||||
<img src="{{ content.image_url }}">
|
<img src="{{ content.image_url }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="index-text">
|
<div class="index-text">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user