Skip to content

Commit

Permalink
Video full size (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuentesloic authored Feb 13, 2020
1 parent 0c85ab9 commit e37a37d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
15 changes: 10 additions & 5 deletions core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ def _replace_embed(match):
youtube_id = extract_youtube_id(url)
if not youtube_id:
return url
return f'''<iframe class=video width=auto height=auto
src=https://www.youtube-nocookie.com/embed/{youtube_id}
frameborder=0 allow="autoplay; encrypted-media" allowfullscreen>
</iframe>
<small>{url}</small>'''
return f'''
<div class=video>
<iframe
src=https://www.youtube-nocookie.com/embed/{youtube_id}
frameborder=0
allow="autoplay; encrypted-media"
allowfullscreen>
</iframe>
<small>{url}</small>
</div>'''


@app.template_filter()
Expand Down
15 changes: 12 additions & 3 deletions static/css/article.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,18 @@ body {
margin-top: 2rem;
}

.blog-article .content a {
color: var(--color-primary);
text-decoration: underline dotted var(--color-primary);
.blog-article .video {
position: relative;
padding-bottom: 56.25%; /* 16:9 */
height: 0;
}

.blog-article .video > iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

.blog-article .content a:active,
Expand Down
2 changes: 0 additions & 2 deletions static/js/article.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
console.debug('>>>', document.querySelectorAll('article .content img'))
debugger
Array.from(document.querySelectorAll('article .content img')).forEach(img => {
const rects = img.getClientRects()[0]
img.style.width = `${rects.right}px`
Expand Down

0 comments on commit e37a37d

Please sign in to comment.