2018-01-20 23:37:40 +00:00
|
|
|
<div class="status-media" style="grid-template-columns: repeat(auto-fit, minmax({{minMediaWidth}}px, 1fr));">
|
|
|
|
{{#each mediaAttachments as media}}
|
2018-01-21 00:18:28 +00:00
|
|
|
<div class="status-media-container {{hasNoNativeWidthHeight(media) ? 'no-native-width-height' : ''}}">
|
2018-01-20 23:37:40 +00:00
|
|
|
{{#if media.type === 'video'}}
|
2018-01-21 00:18:28 +00:00
|
|
|
<video poster="{{media.preview_url}}"
|
2018-01-20 23:37:40 +00:00
|
|
|
src="{{media.url}}"
|
|
|
|
width="{{getSmallWidth(media)}}"
|
|
|
|
height="{{getSmallHeight(media)}}"
|
|
|
|
controls
|
|
|
|
/>
|
2018-01-21 00:18:28 +00:00
|
|
|
{{elseif media.type === 'gifv'}}
|
|
|
|
<video
|
|
|
|
poster="{{media.preview_url}}"
|
|
|
|
src="{{media.url}}"
|
|
|
|
width="{{getSmallWidth(media)}}"
|
|
|
|
height="{{getSmallHeight(media)}}"
|
|
|
|
autoplay
|
|
|
|
muted
|
|
|
|
loop
|
|
|
|
playsinline
|
|
|
|
/>
|
2018-01-20 23:37:40 +00:00
|
|
|
{{else}}
|
2018-01-21 00:18:28 +00:00
|
|
|
<img src="{{media.preview_url}}"
|
2018-01-20 23:37:40 +00:00
|
|
|
alt="{{media.description || ''}}"
|
|
|
|
width="{{getSmallWidth(media)}}"
|
|
|
|
height="{{getSmallHeight(media)}}"/>
|
|
|
|
{{/if}}
|
|
|
|
</div>
|
|
|
|
{{/each}}
|
|
|
|
</div>
|
|
|
|
<style>
|
|
|
|
.status-media {
|
|
|
|
grid-area: status-media;
|
|
|
|
display: grid;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
justify-items: center;
|
|
|
|
grid-column-gap: 10px;
|
|
|
|
grid-row-gap: 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.status-media-container {
|
|
|
|
overflow: hidden;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
}
|
2018-01-21 00:18:28 +00:00
|
|
|
.no-native-width-height img, .no-native-width-height video {
|
2018-01-20 23:37:40 +00:00
|
|
|
background-color: var(--mask-bg);
|
|
|
|
}
|
|
|
|
.status-media {
|
|
|
|
max-width: calc(100vw - 40px);
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.status-media video, .status-media img {
|
|
|
|
max-width: calc(100vw - 40px);
|
|
|
|
object-fit: cover;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
const DEFAULT_MEDIA_WIDTH = 300
|
|
|
|
const DEFAULT_MEDIA_HEIGHT = 200
|
|
|
|
|
|
|
|
export default {
|
|
|
|
helpers: {
|
|
|
|
getSmallWidth: media => media.meta && media.meta.small && typeof media.meta.small.width === 'number' ? media.meta.small.width : DEFAULT_MEDIA_WIDTH,
|
|
|
|
getSmallHeight: media => media.meta && media.meta.small && typeof media.meta.small.height === 'number' ? media.meta.small.height : DEFAULT_MEDIA_HEIGHT,
|
|
|
|
hasNoNativeWidthHeight: media => !(media && media.meta && media.meta.small && typeof media.meta.small.width === 'number' && typeof media.meta.small.height === 'number'),
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
minMediaWidth: (mediaAttachments) => Math.min.apply(Math, mediaAttachments.map(media => media.meta && media.meta.small && typeof media.meta.small.width === 'number' ? media.meta.small.width : DEFAULT_MEDIA_WIDTH))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|