2016-10-28 16:08:03 +00:00
|
|
|
<template>
|
2019-07-05 07:17:44 +00:00
|
|
|
<div
|
2020-06-29 11:48:22 +00:00
|
|
|
v-if="usePlaceholder"
|
2020-07-06 12:06:13 +00:00
|
|
|
:class="{ 'fullwidth': fullwidth }"
|
2019-07-05 07:17:44 +00:00
|
|
|
@click="openModal"
|
|
|
|
>
|
|
|
|
<a
|
2019-01-26 15:45:03 +00:00
|
|
|
v-if="type !== 'html'"
|
2019-07-05 07:17:44 +00:00
|
|
|
class="placeholder"
|
|
|
|
target="_blank"
|
|
|
|
:href="attachment.url"
|
2020-06-29 11:48:22 +00:00
|
|
|
:alt="attachment.description"
|
|
|
|
:title="attachment.description"
|
2019-01-26 15:45:03 +00:00
|
|
|
>
|
2020-10-20 21:01:28 +00:00
|
|
|
<FAIcon :icon="placeholderIconClass" />
|
2020-06-29 11:48:22 +00:00
|
|
|
<b>{{ nsfw ? "NSFW / " : "" }}</b>{{ placeholderName }}
|
2019-01-26 15:45:03 +00:00
|
|
|
</a>
|
2018-04-09 16:43:31 +00:00
|
|
|
</div>
|
2019-01-14 17:23:13 +00:00
|
|
|
<div
|
2019-07-05 07:17:44 +00:00
|
|
|
v-else
|
2019-01-14 17:23:13 +00:00
|
|
|
v-show="!isEmpty"
|
2019-07-05 07:17:44 +00:00
|
|
|
class="attachment"
|
|
|
|
:class="{[type]: true, loading, 'fullwidth': fullwidth, 'nsfw-placeholder': hidden}"
|
2019-01-14 17:23:13 +00:00
|
|
|
>
|
2019-07-05 07:17:44 +00:00
|
|
|
<a
|
|
|
|
v-if="hidden"
|
|
|
|
class="image-attachment"
|
|
|
|
:href="attachment.url"
|
2020-06-29 11:48:22 +00:00
|
|
|
:alt="attachment.description"
|
|
|
|
:title="attachment.description"
|
2020-10-02 09:21:56 +00:00
|
|
|
@click.prevent.stop="toggleHidden"
|
2019-07-05 07:17:44 +00:00
|
|
|
>
|
|
|
|
<img
|
|
|
|
:key="nsfwImage"
|
|
|
|
class="nsfw"
|
|
|
|
:src="nsfwImage"
|
|
|
|
:class="{'small': isSmall}"
|
|
|
|
>
|
2020-10-20 21:01:28 +00:00
|
|
|
<FAIcon
|
2019-07-05 07:17:44 +00:00
|
|
|
v-if="type === 'video'"
|
2020-10-20 21:31:16 +00:00
|
|
|
class="play-icon"
|
|
|
|
icon="play-circle"
|
2019-07-05 07:17:44 +00:00
|
|
|
/>
|
2016-10-28 16:08:03 +00:00
|
|
|
</a>
|
2020-11-24 10:32:42 +00:00
|
|
|
<button
|
2019-07-05 07:17:44 +00:00
|
|
|
v-if="nsfw && hideNsfwLocal && !hidden"
|
2020-11-24 19:35:14 +00:00
|
|
|
class="button-unstyled hider"
|
2020-11-24 10:32:42 +00:00
|
|
|
@click.prevent="toggleHidden"
|
2019-07-05 07:17:44 +00:00
|
|
|
>
|
2020-11-24 10:32:42 +00:00
|
|
|
<FAIcon icon="times" />
|
|
|
|
</button>
|
2019-01-20 10:46:11 +00:00
|
|
|
|
2019-07-05 07:17:44 +00:00
|
|
|
<a
|
|
|
|
v-if="type === 'image' && (!hidden || preloadImage)"
|
2019-01-14 17:23:13 +00:00
|
|
|
class="image-attachment"
|
2019-01-26 15:45:03 +00:00
|
|
|
:class="{'hidden': hidden && preloadImage }"
|
2019-07-05 07:17:44 +00:00
|
|
|
:href="attachment.url"
|
|
|
|
target="_blank"
|
|
|
|
@click="openModal"
|
2019-01-14 17:23:13 +00:00
|
|
|
>
|
2019-07-05 07:17:44 +00:00
|
|
|
<StillImage
|
2020-08-18 20:57:42 +00:00
|
|
|
class="image"
|
2019-07-05 07:17:44 +00:00
|
|
|
:referrerpolicy="referrerpolicy"
|
|
|
|
:mimetype="attachment.mimetype"
|
|
|
|
:src="attachment.large_thumb_url || attachment.url"
|
2019-10-18 20:04:17 +00:00
|
|
|
:image-load-handler="onImageLoad"
|
2019-02-18 05:03:26 +00:00
|
|
|
:alt="attachment.description"
|
2019-07-05 07:17:44 +00:00
|
|
|
/>
|
2016-11-26 00:19:25 +00:00
|
|
|
</a>
|
2016-10-28 16:08:03 +00:00
|
|
|
|
2019-07-05 07:17:44 +00:00
|
|
|
<a
|
2019-01-20 10:46:11 +00:00
|
|
|
v-if="type === 'video' && !hidden"
|
2019-07-05 07:17:44 +00:00
|
|
|
class="video-container"
|
2019-01-20 10:46:11 +00:00
|
|
|
:class="{'small': isSmall}"
|
2019-01-26 15:59:59 +00:00
|
|
|
:href="allowPlay ? undefined : attachment.url"
|
2019-07-05 07:17:44 +00:00
|
|
|
@click="openModal"
|
2019-01-20 10:46:11 +00:00
|
|
|
>
|
2019-07-05 07:17:44 +00:00
|
|
|
<VideoAttachment
|
|
|
|
class="video"
|
|
|
|
:attachment="attachment"
|
|
|
|
:controls="allowPlay"
|
2020-09-29 10:18:37 +00:00
|
|
|
@play="$emit('play')"
|
|
|
|
@pause="$emit('pause')"
|
2019-07-05 07:17:44 +00:00
|
|
|
/>
|
2020-10-20 21:01:28 +00:00
|
|
|
<FAIcon
|
2019-07-05 07:17:44 +00:00
|
|
|
v-if="!allowPlay"
|
2020-10-20 21:31:16 +00:00
|
|
|
class="play-icon"
|
|
|
|
icon="play-circle"
|
2019-07-05 07:17:44 +00:00
|
|
|
/>
|
2019-01-20 10:46:11 +00:00
|
|
|
</a>
|
2016-10-28 16:08:03 +00:00
|
|
|
|
2019-07-05 07:17:44 +00:00
|
|
|
<audio
|
|
|
|
v-if="type === 'audio'"
|
|
|
|
:src="attachment.url"
|
2020-06-29 11:48:22 +00:00
|
|
|
:alt="attachment.description"
|
|
|
|
:title="attachment.description"
|
2019-07-05 07:17:44 +00:00
|
|
|
controls
|
2020-09-29 10:18:37 +00:00
|
|
|
@play="$emit('play')"
|
|
|
|
@pause="$emit('pause')"
|
2019-07-05 07:17:44 +00:00
|
|
|
/>
|
2016-11-22 18:45:18 +00:00
|
|
|
|
2019-07-05 07:17:44 +00:00
|
|
|
<div
|
|
|
|
v-if="type === 'html' && attachment.oembed"
|
|
|
|
class="oembed"
|
|
|
|
@click.prevent="linkClicked"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
v-if="attachment.thumb_url"
|
|
|
|
class="image"
|
|
|
|
>
|
|
|
|
<img :src="attachment.thumb_url">
|
2016-10-28 23:38:41 +00:00
|
|
|
</div>
|
|
|
|
<div class="text">
|
2019-07-06 21:54:17 +00:00
|
|
|
<!-- eslint-disable vue/no-v-html -->
|
2019-07-05 07:17:44 +00:00
|
|
|
<h1><a :href="attachment.url">{{ attachment.oembed.title }}</a></h1>
|
|
|
|
<div v-html="attachment.oembed.oembedHTML" />
|
2019-07-12 19:11:54 +00:00
|
|
|
<!-- eslint-enable vue/no-v-html -->
|
2016-10-28 23:38:41 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2016-10-28 16:08:03 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script src="./attachment.js"></script>
|
2016-10-28 23:38:41 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
2018-04-01 02:28:20 +00:00
|
|
|
@import '../../_variables.scss';
|
|
|
|
|
2018-03-31 18:14:36 +00:00
|
|
|
.attachments {
|
2018-04-07 16:30:27 +00:00
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
2020-06-29 11:48:22 +00:00
|
|
|
.non-gallery {
|
2018-04-07 16:30:27 +00:00
|
|
|
max-width: 100%;
|
2018-04-09 21:28:24 +00:00
|
|
|
}
|
2018-04-07 18:58:29 +00:00
|
|
|
|
2018-04-09 21:28:24 +00:00
|
|
|
.placeholder {
|
2020-06-29 11:48:22 +00:00
|
|
|
display: inline-block;
|
|
|
|
padding: 0.3em 1em 0.3em 0;
|
2020-02-11 23:26:01 +00:00
|
|
|
color: $fallback--link;
|
|
|
|
color: var(--postLink, $fallback--link);
|
2020-06-29 11:48:22 +00:00
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
max-width: 100%;
|
2020-10-20 21:01:28 +00:00
|
|
|
|
|
|
|
svg {
|
|
|
|
color: inherit;
|
|
|
|
}
|
2018-04-09 21:28:24 +00:00
|
|
|
}
|
|
|
|
|
2018-08-15 08:20:40 +00:00
|
|
|
.nsfw-placeholder {
|
|
|
|
cursor: pointer;
|
2018-08-30 13:11:31 +00:00
|
|
|
|
|
|
|
&.loading {
|
|
|
|
cursor: progress;
|
|
|
|
}
|
2018-08-15 08:20:40 +00:00
|
|
|
}
|
|
|
|
|
2018-04-07 16:30:27 +00:00
|
|
|
.attachment {
|
2018-08-30 13:21:10 +00:00
|
|
|
position: relative;
|
2019-03-02 16:35:38 +00:00
|
|
|
margin-top: 0.5em;
|
2018-04-07 16:30:27 +00:00
|
|
|
align-self: flex-start;
|
2018-04-10 19:12:59 +00:00
|
|
|
line-height: 0;
|
2018-04-07 16:30:27 +00:00
|
|
|
|
|
|
|
border-style: solid;
|
|
|
|
border-width: 1px;
|
|
|
|
border-radius: $fallback--attachmentRadius;
|
|
|
|
border-radius: var(--attachmentRadius, $fallback--attachmentRadius);
|
2018-04-09 21:28:24 +00:00
|
|
|
border-color: $fallback--border;
|
|
|
|
border-color: var(--border, $fallback--border);
|
2018-04-07 16:30:27 +00:00
|
|
|
overflow: hidden;
|
2018-04-09 21:28:24 +00:00
|
|
|
}
|
2019-01-26 15:45:03 +00:00
|
|
|
|
|
|
|
.non-gallery.attachment {
|
|
|
|
&.video {
|
|
|
|
flex: 1 0 40%;
|
|
|
|
}
|
|
|
|
.nsfw {
|
|
|
|
height: 260px;
|
|
|
|
}
|
|
|
|
.small {
|
|
|
|
height: 120px;
|
|
|
|
flex-grow: 0;
|
|
|
|
}
|
|
|
|
.video {
|
|
|
|
height: 260px;
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
video {
|
|
|
|
max-height: 100%;
|
|
|
|
object-fit: contain;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-14 12:45:38 +00:00
|
|
|
.fullwidth {
|
|
|
|
flex-basis: 100%;
|
|
|
|
}
|
2018-04-09 21:28:24 +00:00
|
|
|
// fixes small gap below video
|
|
|
|
&.video {
|
|
|
|
line-height: 0;
|
|
|
|
}
|
2018-04-07 16:30:27 +00:00
|
|
|
|
2019-01-20 10:46:11 +00:00
|
|
|
.video-container {
|
2019-01-26 15:45:03 +00:00
|
|
|
display: flex;
|
|
|
|
max-height: 100%;
|
2019-01-20 10:46:11 +00:00
|
|
|
}
|
|
|
|
|
2019-01-14 17:23:13 +00:00
|
|
|
.video {
|
2019-01-26 15:45:03 +00:00
|
|
|
width: 100%;
|
2019-08-26 11:08:30 +00:00
|
|
|
height: 100%;
|
2019-01-14 17:23:13 +00:00
|
|
|
}
|
|
|
|
|
2019-01-20 10:46:11 +00:00
|
|
|
.play-icon {
|
|
|
|
position: absolute;
|
|
|
|
font-size: 64px;
|
|
|
|
top: calc(50% - 32px);
|
|
|
|
left: calc(50% - 32px);
|
|
|
|
color: rgba(255, 255, 255, 0.75);
|
|
|
|
text-shadow: 0 0 2px rgba(0, 0, 0, 0.4);
|
|
|
|
}
|
|
|
|
|
|
|
|
.play-icon::before {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
2018-04-09 21:28:24 +00:00
|
|
|
&.html {
|
|
|
|
flex-basis: 90%;
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
}
|
2018-03-31 18:14:36 +00:00
|
|
|
|
2018-04-09 21:28:24 +00:00
|
|
|
.hider {
|
|
|
|
position: absolute;
|
2019-02-14 17:21:10 +00:00
|
|
|
right: 0;
|
2018-04-09 21:28:24 +00:00
|
|
|
margin: 10px;
|
2020-11-24 19:35:14 +00:00
|
|
|
padding: 0;
|
2018-04-09 21:28:24 +00:00
|
|
|
z-index: 4;
|
2018-04-15 13:45:05 +00:00
|
|
|
border-radius: $fallback--tooltipRadius;
|
|
|
|
border-radius: var(--tooltipRadius, $fallback--tooltipRadius);
|
2020-11-24 10:32:42 +00:00
|
|
|
text-align: center;
|
|
|
|
width: 2em;
|
|
|
|
height: 2em;
|
|
|
|
font-size: 1.25em;
|
|
|
|
// TODO: theming? hard to theme with unknown background image color
|
|
|
|
background: rgba(230, 230, 230, 0.7);
|
|
|
|
.svg-inline--fa {
|
|
|
|
color: rgba(0, 0, 0, 0.6);
|
|
|
|
}
|
|
|
|
&:hover .svg-inline--fa {
|
|
|
|
color: rgba(0, 0, 0, 0.9);
|
|
|
|
}
|
2018-04-09 21:28:24 +00:00
|
|
|
}
|
2017-02-17 09:16:29 +00:00
|
|
|
|
2018-04-09 21:28:24 +00:00
|
|
|
video {
|
|
|
|
z-index: 0;
|
|
|
|
}
|
2018-03-31 18:14:36 +00:00
|
|
|
|
2018-04-09 21:28:24 +00:00
|
|
|
audio {
|
|
|
|
width: 100%;
|
|
|
|
}
|
2018-03-31 18:14:36 +00:00
|
|
|
|
2018-04-09 21:28:24 +00:00
|
|
|
img.media-upload {
|
2018-04-10 19:12:59 +00:00
|
|
|
line-height: 0;
|
2019-01-26 15:45:03 +00:00
|
|
|
max-height: 200px;
|
2018-04-09 21:28:24 +00:00
|
|
|
max-width: 100%;
|
|
|
|
}
|
2018-03-31 18:14:36 +00:00
|
|
|
|
2018-04-09 21:28:24 +00:00
|
|
|
.oembed {
|
2018-04-11 16:47:03 +00:00
|
|
|
line-height: 1.2em;
|
2018-04-14 12:45:38 +00:00
|
|
|
flex: 1 0 100%;
|
2018-04-09 21:28:24 +00:00
|
|
|
width: 100%;
|
|
|
|
margin-right: 15px;
|
|
|
|
display: flex;
|
2018-03-31 18:14:36 +00:00
|
|
|
|
2018-04-09 21:28:24 +00:00
|
|
|
img {
|
2018-04-07 16:30:27 +00:00
|
|
|
width: 100%;
|
2018-04-09 21:28:24 +00:00
|
|
|
}
|
2018-04-07 16:30:27 +00:00
|
|
|
|
2018-04-09 21:28:24 +00:00
|
|
|
.image {
|
|
|
|
flex: 1;
|
2018-04-07 16:30:27 +00:00
|
|
|
img {
|
2018-04-09 21:28:24 +00:00
|
|
|
border: 0px;
|
2018-04-09 16:43:31 +00:00
|
|
|
border-radius: 5px;
|
2018-04-09 21:28:24 +00:00
|
|
|
height: 100%;
|
|
|
|
object-fit: cover;
|
2018-04-09 16:43:31 +00:00
|
|
|
}
|
2018-04-09 21:28:24 +00:00
|
|
|
}
|
2018-04-07 16:30:27 +00:00
|
|
|
|
2018-04-09 21:28:24 +00:00
|
|
|
.text {
|
|
|
|
flex: 2;
|
|
|
|
margin: 8px;
|
|
|
|
word-break: break-all;
|
|
|
|
h1 {
|
|
|
|
font-size: 14px;
|
|
|
|
margin: 0px;
|
2018-04-09 16:43:31 +00:00
|
|
|
}
|
2018-04-07 16:30:27 +00:00
|
|
|
}
|
2018-04-09 21:28:24 +00:00
|
|
|
}
|
2017-11-12 21:50:18 +00:00
|
|
|
|
2018-04-09 21:28:24 +00:00
|
|
|
.image-attachment {
|
2020-08-18 20:57:42 +00:00
|
|
|
&,
|
|
|
|
& .image {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
2017-02-17 09:16:29 +00:00
|
|
|
|
2018-12-11 20:58:36 +00:00
|
|
|
&.hidden {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2019-01-26 15:45:03 +00:00
|
|
|
.nsfw {
|
|
|
|
object-fit: cover;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
2018-03-31 18:14:36 +00:00
|
|
|
}
|
2018-04-09 21:28:24 +00:00
|
|
|
|
|
|
|
img {
|
2019-08-26 11:08:30 +00:00
|
|
|
image-orientation: from-image; // NOTE: only FF supports this
|
2018-04-09 21:28:24 +00:00
|
|
|
}
|
2018-04-07 16:30:27 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-28 23:38:41 +00:00
|
|
|
</style>
|