Improved image and attachment viewing on part info page

This commit is contained in:
Jan Böhmer 2023-07-23 01:32:28 +02:00
parent 1de1eebc59
commit fc7e436ca9
3 changed files with 12 additions and 3 deletions

View file

@ -58,6 +58,14 @@ class PartPreviewGenerator
$list[] = $attachment; $list[] = $attachment;
} }
//Then comes the other images of the part
foreach ($part->getAttachments() as $attachment) {
//Dont show the master attachment twice
if ($this->isAttachmentValidPicture($attachment) && $attachment !== $part->getMasterPictureAttachment()) {
$list[] = $attachment;
}
}
if ($part->getFootprint() instanceof Footprint) { if ($part->getFootprint() instanceof Footprint) {
$attachment = $part->getFootprint()->getMasterPictureAttachment(); $attachment = $part->getFootprint()->getMasterPictureAttachment();
if ($this->isAttachmentValidPicture($attachment)) { if ($this->isAttachmentValidPicture($attachment)) {

View file

@ -19,14 +19,15 @@
</div> </div>
{% endmacro %} {% endmacro %}
{% macro attachment_icon(attachment, attachment_helper, class = "fa-fw fas fa-3x hoverpic", link = true) %} {% macro attachment_icon(attachment, attachment_helper, class = "fa-fw fas fa-2x hoverpic", link = true) %}
{# @var App\Entity\Attachments\Attachment attachment #}
{% set disabled = attachment.secure and not is_granted("show_private", attachment) %} {% set disabled = attachment.secure and not is_granted("show_private", attachment) %}
{% if not attachment_helper or attachment_helper.fileExisting(attachment) %} {% if not attachment_helper or attachment_helper.fileExisting(attachment) %}
{% if link and not disabled %} {% if link and not disabled %}
<a target="_blank" data-turbo="false" rel="noopener" href="{{ entity_url(attachment, 'file_view') }}"> <a target="_blank" data-turbo="false" rel="noopener" href="{{ entity_url(attachment, 'file_view') }}">
{% endif %} {% endif %}
{% if attachment.picture %} {% if attachment.picture %}
<img class="hoverpic" {{ stimulus_controller('elements/hoverpic') }} data-thumbnail="{{ entity_url(attachment, 'file_view') }}" src="{{ entity_url(attachment, 'file_view') }}"> <img class="hoverpic" {{ stimulus_controller('elements/hoverpic') }} data-title="{{ attachment.name }}" data-thumbnail="{{ entity_url(attachment, 'file_view') }}" src="{{ entity_url(attachment, 'file_view') }}">
{% else %} {% else %}
<i class="text-dark {{ class }} {{ ext_to_fa_icon(attachment.extension) }}"></i> <i class="text-dark {{ class }} {{ ext_to_fa_icon(attachment.extension) }}"></i>
{% endif %} {% endif %}

View file

@ -15,7 +15,7 @@
<img class="d-block w-100 img-fluid img-thumbnail bg-light part-info-image" src="{{ entity_url(pic, 'file_view') }}" alt=""> <img class="d-block w-100 img-fluid img-thumbnail bg-light part-info-image" src="{{ entity_url(pic, 'file_view') }}" alt="">
<div class="mask"></div> <div class="mask"></div>
<div class="carousel-caption-hover"> <div class="carousel-caption-hover">
<div class="carousel-caption text-body "> <div class="carousel-caption text-white">
<div><b>{{ pic.name }}</b></div> <div><b>{{ pic.name }}</b></div>
<div>{% if pic.filename %}({{ pic.filename }}) {% endif %}</div> <div>{% if pic.filename %}({{ pic.filename }}) {% endif %}</div>
<div>{{ entity_type_label(pic.element) }}</div> <div>{{ entity_type_label(pic.element) }}</div>