[COMPONENT][Attachment] Do not show download links for non-local attachments

This commit is contained in:
Diogo Peralta Cordeiro 2021-12-03 02:22:50 +00:00
parent ff5f346fec
commit 582519e13e
No known key found for this signature in database
GPG Key ID: 18D2D35001FBFAB0
5 changed files with 24 additions and 10 deletions

View File

@ -2,8 +2,12 @@
<figure>
<audio class="u-audio" src="{{ attachment.getUrl() }}" controls>
</audio>
<figcaption><a
href="{{ path('attachment_show', {'id': attachment.getId()}) }}">{{ attachment.getBestTitle(note) }}</a>
<figcaption>
{% if attachment.getFilename() is not null %}
<a href="{{ path('attachment_show', {'id': attachment.getId()}) }}">{{ attachment.getBestTitle(note) }}</a>
{% else %}
{{ attachment.getBestTitle(note) }}
{% endif %}
</figcaption>
</figure>
</div>

View File

@ -5,7 +5,11 @@
src="{{ attachment.getThumbnailUrl() }}"
width="{{ thumbnail.getWidth() }}"
height="{{ thumbnail.getHeight() }}">
<figcaption><a
href="{{ path('attachment_show', {'id': attachment.getId()}) }}">{{ attachment.getBestTitle(note) }}</a>
</figcaption>
<figcaption>
{% if attachment.getFilename() is not null %}
<a href="{{ path('attachment_show', {'id': attachment.getId()}) }}">{{ attachment.getBestTitle(note) }}</a>
{% else %}
{{ attachment.getBestTitle(note) }}
{% endif %}
</figcaption>
</figure>

View File

@ -78,7 +78,7 @@ class StoreRemoteMedia extends Plugin
private function getStoreOriginal(): bool
{
return $this->store_original;
return $this->store_original ?? Common::config('plugin_store_remote_media', 'store_original');
}
private function getThumbnailWidth(): int
@ -93,12 +93,12 @@ class StoreRemoteMedia extends Plugin
private function getMaxSize(): int
{
return $this->max_size ?? Common::config('attachments', 'file_quota');
return $this->max_size ?? Common::config('plugin_store_remote_media', 'max_file_size');
}
private function getSmartCrop(): bool
{
return $this->smart_crop ?? Common::config('thumbnail', 'smart_crop');
return $this->smart_crop ?? Common::config('plugin_store_remote_media', 'smart_crop');
}
/**
@ -127,6 +127,7 @@ class StoreRemoteMedia extends Plugin
);
// If it was handled already
// XXX: Maybe it would be interesting to have retroactive application of $this->getOriginal here
if (!\is_null($attachment_to_link)) {
// Relate the note with the existing attachment
DB::persist(AttachmentToNote::create([

View File

@ -2,8 +2,12 @@
<figure>
<video class="u-video" src="{{ attachment.getUrl() }}" controls poster="{{ attachment.getThumbnailUrl('medium')}}">
</video>
<figcaption><a
href="{{ path('attachment_show', {'id': attachment.getId()}) }}">{{ attachment.getBestTitle(note) }}</a>
<figcaption>
{% if attachment.getFilename() is not null %}
<a href="{{ path('attachment_show', {'id': attachment.getId()}) }}">{{ attachment.getBestTitle(note) }}</a>
{% else %}
{{ attachment.getBestTitle(note) }}
{% endif %}
</figcaption>
</figure>
</div>

View File

@ -129,6 +129,7 @@ parameters:
extension: '.webp'
plugin_store_remote_media:
store_original: false
max_file_size: 4000000
smart_crop: false