Adds mimetypes as placeholders to items list. #456.

This commit is contained in:
mateuswetah 2020-12-18 12:22:24 -03:00
parent 502a9fb0ee
commit ee86376871
15 changed files with 134 additions and 125 deletions

172
composer.lock generated
View File

@ -4,8 +4,51 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "e2a614836d1857e45c4f9be57073c2b2", "content-hash": "666f5355343e235ef29dd8eaae61ad43",
"packages": [ "packages": [
{
"name": "kornrunner/blurhash",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://github.com/kornrunner/php-blurhash.git",
"reference": "5a09325353229c108c8d2ff129ec08b447753f9b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/kornrunner/php-blurhash/zipball/5a09325353229c108c8d2ff129ec08b447753f9b",
"reference": "5a09325353229c108c8d2ff129ec08b447753f9b",
"shasum": ""
},
"require": {
"php": "^7.2"
},
"require-dev": {
"ocramius/package-versions": "<1.5",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^8.2",
"vimeo/psalm": "^3.4"
},
"type": "library",
"autoload": {
"psr-4": {
"kornrunner\\Blurhash\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Boris Momčilović",
"email": "boris.momcilovic@gmail.com"
}
],
"description": "Pure PHP implementation of Blurhash",
"homepage": "https://github.com/kornrunner/php-blurhash",
"time": "2020-04-15T22:06:04+00:00"
},
{ {
"name": "respect/validation", "name": "respect/validation",
"version": "1.1.31", "version": "1.1.31",
@ -71,26 +114,26 @@
}, },
{ {
"name": "smalot/pdfparser", "name": "smalot/pdfparser",
"version": "v0.14.0", "version": "v0.17.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/smalot/pdfparser.git", "url": "https://github.com/smalot/pdfparser.git",
"reference": "ec72a99028ba5e21a0acad92047b85e128cbf81f" "reference": "dc1e42293e7774353003b754cce9c64dd9546c2d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/smalot/pdfparser/zipball/ec72a99028ba5e21a0acad92047b85e128cbf81f", "url": "https://api.github.com/repos/smalot/pdfparser/zipball/dc1e42293e7774353003b754cce9c64dd9546c2d",
"reference": "ec72a99028ba5e21a0acad92047b85e128cbf81f", "reference": "dc1e42293e7774353003b754cce9c64dd9546c2d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-mbstring": "*",
"ext-zlib": "*", "ext-zlib": "*",
"php": ">=5.3.0", "php": ">=5.6",
"tecnickcom/tcpdf": "~6.0" "symfony/polyfill-mbstring": "^1.18.1"
}, },
"require-dev": { "require-dev": {
"atoum/atoum": "^2.8 | ^3.0" "friendsofphp/php-cs-fixer": "^2.16.3",
"symfony/phpunit-bridge": "^4.2.3"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -104,12 +147,12 @@
], ],
"authors": [ "authors": [
{ {
"name": "Sebastien Malot", "name": "Sebastien MALOT",
"email": "sebastien@malot.fr" "email": "sebastien@malot.fr"
} }
], ],
"description": "Pdf parser library. Can read and extract information from pdf file.", "description": "Pdf parser library. Can read and extract information from pdf file.",
"homepage": "http://www.pdfparser.org", "homepage": "https://www.pdfparser.org",
"keywords": [ "keywords": [
"extract", "extract",
"parse", "parse",
@ -117,24 +160,24 @@
"pdf", "pdf",
"text" "text"
], ],
"time": "2019-01-23T09:14:37+00:00" "time": "2020-10-29T20:59:50+00:00"
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.12.0", "version": "v1.20.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" "reference": "39d483bdf39be819deabf04ec872eb0b2410b531"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/39d483bdf39be819deabf04ec872eb0b2410b531",
"reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", "reference": "39d483bdf39be819deabf04ec872eb0b2410b531",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.3" "php": ">=7.1"
}, },
"suggest": { "suggest": {
"ext-mbstring": "For best performance" "ext-mbstring": "For best performance"
@ -142,7 +185,11 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.12-dev" "dev-main": "1.20-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
} }
}, },
"autoload": { "autoload": {
@ -176,84 +223,36 @@
"portable", "portable",
"shim" "shim"
], ],
"time": "2019-08-06T08:03:45+00:00" "funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
}, },
{ {
"name": "tecnickcom/tcpdf", "url": "https://github.com/fabpot",
"version": "6.2.26", "type": "github"
"source": {
"type": "git",
"url": "https://github.com/tecnickcom/TCPDF.git",
"reference": "367241059ca166e3a76490f4448c284e0a161f15"
}, },
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/367241059ca166e3a76490f4448c284e0a161f15",
"reference": "367241059ca166e3a76490f4448c284e0a161f15",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"classmap": [
"config",
"include",
"tcpdf.php",
"tcpdf_parser.php",
"tcpdf_import.php",
"tcpdf_barcodes_1d.php",
"tcpdf_barcodes_2d.php",
"include/tcpdf_colors.php",
"include/tcpdf_filters.php",
"include/tcpdf_font_data.php",
"include/tcpdf_fonts.php",
"include/tcpdf_images.php",
"include/tcpdf_static.php",
"include/barcodes/datamatrix.php",
"include/barcodes/pdf417.php",
"include/barcodes/qrcode.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0"
],
"authors": [
{ {
"name": "Nicola Asuni", "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"email": "info@tecnick.com", "type": "tidelift"
"role": "lead"
} }
], ],
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.", "time": "2020-10-23T14:02:19+00:00"
"homepage": "http://www.tcpdf.org/",
"keywords": [
"PDFD32000-2008",
"TCPDF",
"barcodes",
"datamatrix",
"pdf",
"pdf417",
"qrcode"
],
"time": "2018-10-16T17:24:05+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
{ {
"name": "squizlabs/php_codesniffer", "name": "squizlabs/php_codesniffer",
"version": "3.4.2", "version": "3.5.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8" "reference": "9d583721a7157ee997f235f327de038e7ea6dac4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8", "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4",
"reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8", "reference": "9d583721a7157ee997f235f327de038e7ea6dac4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -291,20 +290,20 @@
"phpcs", "phpcs",
"standards" "standards"
], ],
"time": "2019-04-10T23:49:02+00:00" "time": "2020-10-23T02:01:07+00:00"
}, },
{ {
"name": "wimg/php-compatibility", "name": "wimg/php-compatibility",
"version": "9.3.1", "version": "9.3.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHPCompatibility/PHPCompatibility.git", "url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
"reference": "9999344e47e7af6b00e1a898eacc4e4368fb7196" "reference": "9fb324479acf6f39452e0655d2429cc0d3914243"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9999344e47e7af6b00e1a898eacc4e4368fb7196", "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243",
"reference": "9999344e47e7af6b00e1a898eacc4e4368fb7196", "reference": "9fb324479acf6f39452e0655d2429cc0d3914243",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -350,7 +349,7 @@
"standards" "standards"
], ],
"abandoned": "phpcompatibility/php-compatibility", "abandoned": "phpcompatibility/php-compatibility",
"time": "2019-09-05T18:36:49+00:00" "time": "2019-12-27T09:44:58+00:00"
} }
], ],
"aliases": [], "aliases": [],
@ -359,5 +358,6 @@
"prefer-stable": true, "prefer-stable": true,
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": [],
"platform-dev": [] "platform-dev": [],
"plugin-api-version": "1.1.0"
} }

View File

@ -283,6 +283,7 @@ class REST_Items_Controller extends REST_Controller {
if( isset($item_arr['thumbnail']) ) { if( isset($item_arr['thumbnail']) ) {
$item_arr['thumbnail_alt'] = get_post_meta( $item->get__thumbnail_id(), '_wp_attachment_image_alt', true ); $item_arr['thumbnail_alt'] = get_post_meta( $item->get__thumbnail_id(), '_wp_attachment_image_alt', true );
$item_arr['thumbnail_id'] = $item->get__thumbnail_id(); $item_arr['thumbnail_id'] = $item->get__thumbnail_id();
$item_arr['document_mimetype'] = $item->get_document_mimetype(); // In case the thumbnail is requested, we need the document mime type to generate proper placeholders
} }
$item_arr['url'] = get_permalink( $item_arr['id'] ); $item_arr['url'] = get_permalink( $item_arr['id'] );

View File

@ -89,7 +89,7 @@
v-if="item.document != undefined && item.document != '' && item.document_type != 'empty'" v-if="item.document != undefined && item.document != '' && item.document_type != 'empty'"
class="document-thumb" class="document-thumb"
:alt="$i18n.get('label_thumbnail') + ': ' + item.title" :alt="$i18n.get('label_thumbnail') + ': ' + item.title"
:src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_type)" > :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_mimetype)" >
<span <span
class="document-name" class="document-name"
v-html="item.title" /> v-html="item.title" />

View File

@ -305,17 +305,21 @@
:size="178" :size="178"
:file="{ :file="{
media_type: 'image', media_type: 'image',
thumbnails: { 'tainacan-medium': [ $thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_type) ] }, thumbnails: { 'tainacan-medium': [ $thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_mimetype) ] },
title: $i18n.get('label_thumbnail'), title: $i18n.get('label_thumbnail'),
description: `<img alt='` + $i18n.get('label_thumbnail') + `' src='` + $thumbHelper.getSrc(item['thumbnail'], 'full', item.document_type) + `'/>` description: `<img alt='` + $i18n.get('label_thumbnail') + `' src='` + $thumbHelper.getSrc(item['thumbnail'], 'full', item.document_mimetype) + `'/>`
}"/> }"/>
<figure <figure
v-if="item.thumbnail == undefined || ((item.thumbnail.medium == undefined || item.thumbnail.medium == false) && (item.thumbnail['tainacan-medium'] == undefined || item.thumbnail['tainacan-medium'] == false))" v-if="item.thumbnail == undefined || ((item.thumbnail.medium == undefined || item.thumbnail.medium == false) && (item.thumbnail['tainacan-medium'] == undefined || item.thumbnail['tainacan-medium'] == false))"
class="image"> class="image">
<span class="image-placeholder">{{ $i18n.get('label_empty_thumbnail') }}</span> <span
class="image-placeholder"
v-if="item.document_type == 'empty'">
{{ $i18n.get('label_empty_thumbnail') }}
</span>
<img <img
:alt="$i18n.get('label_thumbnail')" :alt="$i18n.get('label_thumbnail')"
:src="$thumbHelper.getEmptyThumbnailPlaceholder(item.document_type)"> :src="$thumbHelper.getEmptyThumbnailPlaceholder(item.document_mimetype)">
</figure> </figure>
<div class="thumbnail-buttons-row"> <div class="thumbnail-buttons-row">
<a <a

View File

@ -157,7 +157,7 @@
let metadata = this.query.metaquery[ index ]; let metadata = this.query.metaquery[ index ];
if (this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship') { if (this.metadatumType === 'Tainacan\\Metadata_Types\\Relationship') {
let query = qs.stringify({ postin: metadata.value, fetch_only: 'title,thumbnail,document_type', fetch_only_meta: '' }); let query = qs.stringify({ postin: metadata.value, fetch_only: 'title,thumbnail,document_mimetype', fetch_only_meta: '' });
let endpoint = '/items/'; let endpoint = '/items/';
if (this.relatedCollectionId != '') if (this.relatedCollectionId != '')
@ -173,7 +173,7 @@
this.selected.push({ this.selected.push({
label: item.title, label: item.title,
value: item.id, value: item.id,
img: item.thumbnail ? this.$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_type) : null img: item.thumbnail ? this.$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_mimetype) : null
}); });
} }
} }

View File

@ -181,7 +181,7 @@
:width="$thumbHelper.getWidth(item['thumbnail'], 'tainacan-medium', 120)" :width="$thumbHelper.getWidth(item['thumbnail'], 'tainacan-medium', 120)"
:height="$thumbHelper.getHeight(item['thumbnail'], 'tainacan-medium', 120)" :height="$thumbHelper.getHeight(item['thumbnail'], 'tainacan-medium', 120)"
:hash="$thumbHelper.getBlurhashString(item['thumbnail'], 'tainacan-medium')" :hash="$thumbHelper.getBlurhashString(item['thumbnail'], 'tainacan-medium')"
:src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_type)" :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_mimetype)"
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')" :alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
:transition-duration="500" :transition-duration="500"
/> />
@ -298,8 +298,8 @@
:width="$thumbHelper.getWidth(item['thumbnail'], 'tainacan-medium-full', 120)" :width="$thumbHelper.getWidth(item['thumbnail'], 'tainacan-medium-full', 120)"
:height="$thumbHelper.getHeight(item['thumbnail'], 'tainacan-medium-full', 120)" :height="$thumbHelper.getHeight(item['thumbnail'], 'tainacan-medium-full', 120)"
:hash="$thumbHelper.getBlurhashString(item['thumbnail'], 'tainacan-medium-full')" :hash="$thumbHelper.getBlurhashString(item['thumbnail'], 'tainacan-medium-full')"
:src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_type)" :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)"
:srcset="$thumbHelper.getSrcSet(item['thumbnail'], 'tainacan-medium-full', item.document_type)" :srcset="$thumbHelper.getSrcSet(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)"
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')" :alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
:transition-duration="500" :transition-duration="500"
/> />
@ -473,7 +473,7 @@
:width="$thumbHelper.getWidth(item['thumbnail'], 'tainacan-medium', 120)" :width="$thumbHelper.getWidth(item['thumbnail'], 'tainacan-medium', 120)"
:height="$thumbHelper.getHeight(item['thumbnail'], 'tainacan-medium', 120)" :height="$thumbHelper.getHeight(item['thumbnail'], 'tainacan-medium', 120)"
:hash="$thumbHelper.getBlurhashString(item['thumbnail'], 'tainacan-medium')" :hash="$thumbHelper.getBlurhashString(item['thumbnail'], 'tainacan-medium')"
:src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_type)" :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_mimetype)"
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')" :alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
:transition-duration="500" :transition-duration="500"
/> />
@ -669,7 +669,7 @@
<img <img
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')" :alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
v-if="item.thumbnail != undefined" v-if="item.thumbnail != undefined"
:src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_type)"> :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)">
</div> </div>
<span <span
v-for="(column, metadatumIndex) in displayedMetadata" v-for="(column, metadatumIndex) in displayedMetadata"
@ -846,7 +846,7 @@
:width="$thumbHelper.getWidth(item['thumbnail'], 'tainacan-small', 40)" :width="$thumbHelper.getWidth(item['thumbnail'], 'tainacan-small', 40)"
:height="$thumbHelper.getHeight(item['thumbnail'], 'tainacan-small', 40)" :height="$thumbHelper.getHeight(item['thumbnail'], 'tainacan-small', 40)"
:hash="$thumbHelper.getBlurhashString(item['thumbnail'], 'tainacan-small')" :hash="$thumbHelper.getBlurhashString(item['thumbnail'], 'tainacan-small')"
:src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_type)" :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_mimetype)"
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')" :alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
:transition-duration="500" :transition-duration="500"
/> />
@ -1056,14 +1056,14 @@
:width="$thumbHelper.getWidth(item['thumbnail'], 'tainacan-medium-full', 120)" :width="$thumbHelper.getWidth(item['thumbnail'], 'tainacan-medium-full', 120)"
:height="$thumbHelper.getHeight(item['thumbnail'], 'tainacan-medium-full', 120)" :height="$thumbHelper.getHeight(item['thumbnail'], 'tainacan-medium-full', 120)"
:hash="$thumbHelper.getBlurhashString(item['thumbnail'], 'tainacan-medium-full')" :hash="$thumbHelper.getBlurhashString(item['thumbnail'], 'tainacan-medium-full')"
:src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_type)" :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)"
:srcset="$thumbHelper.getSrcSet(item['thumbnail'], 'tainacan-medium-full', item.document_type)" :srcset="$thumbHelper.getSrcSet(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)"
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')" :alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
:transition-duration="500" :transition-duration="500"
/> --> /> -->
<img <img
src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_type)" src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)"
:srcset="$thumbHelper.getSrcSet(item['thumbnail'], 'tainacan-medium-full', item.document_type)" :srcset="$thumbHelper.getSrcSet(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)"
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"> :alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')">
</div> </div>
<div class="list-metadata media-body"> <div class="list-metadata media-body">

View File

@ -120,14 +120,14 @@
if (this.itemMetadatum.value && (Array.isArray( this.itemMetadatum.value ) ? this.itemMetadatum.value.length > 0 : true )) { if (this.itemMetadatum.value && (Array.isArray( this.itemMetadatum.value ) ? this.itemMetadatum.value.length > 0 : true )) {
let query = qs.stringify({ postin: ( Array.isArray( this.itemMetadatum.value ) ) ? this.itemMetadatum.value : [ this.itemMetadatum.value ] }); let query = qs.stringify({ postin: ( Array.isArray( this.itemMetadatum.value ) ) ? this.itemMetadatum.value : [ this.itemMetadatum.value ] });
query += this.itemMetadatum.metadatum.metadata_type_options.search ? '&fetch_only_meta=' + this.itemMetadatum.metadatum.metadata_type_options.search : ''; query += this.itemMetadatum.metadatum.metadata_type_options.search ? '&fetch_only_meta=' + this.itemMetadatum.metadatum.metadata_type_options.search : '';
axios.get('/collection/' + this.collectionId + '/items?' + query + '&nopaging=1&fetch_only=title,document_type,thumbnail&order=asc') axios.get('/collection/' + this.collectionId + '/items?' + query + '&nopaging=1&fetch_only=title,document_mimetype,thumbnail&order=asc')
.then( res => { .then( res => {
if (res.data.items) { if (res.data.items) {
for (let item of res.data.items) for (let item of res.data.items)
this.selected.push({ this.selected.push({
label: this.getItemLabel(item), label: this.getItemLabel(item),
value: item.id, value: item.id,
img: this.$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_type) img: this.$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_mimetype)
}); });
} }
}) })
@ -194,7 +194,7 @@
this.options.push({ this.options.push({
label: this.getItemLabel(item), label: this.getItemLabel(item),
value: item.id, value: item.id,
img: this.$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_type) img: this.$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_mimetype)
}) })
} }
if (res.headers['x-wp-total']) if (res.headers['x-wp-total'])

View File

@ -377,7 +377,7 @@ ThumbnailHelperPlugin.install = function (Vue, options = {}) {
}, },
getBlurhashString(thumbnail, tainacanSize) { getBlurhashString(thumbnail, tainacanSize) {
const wordpressSize = this.getWordpressFallbackSize(tainacanSize); const wordpressSize = this.getWordpressFallbackSize(tainacanSize);
return (thumbnail && thumbnail[tainacanSize]) ? thumbnail[tainacanSize][4] : ((thumbnail && thumbnail[wordpressSize]) ? thumbnail[wordpressSize][4] : ''); return (thumbnail && thumbnail[tainacanSize]) ? thumbnail[tainacanSize][4] : ((thumbnail && thumbnail[wordpressSize]) ? thumbnail[wordpressSize][4] : 'V4P?:h00Rj~qM{of%MRjWBRjD%%MRjayofj[%M-;RjRj');
}, },
getEmptyThumbnailPlaceholder(documentType, tainacanSize) { getEmptyThumbnailPlaceholder(documentType, tainacanSize) {
@ -412,7 +412,7 @@ ThumbnailHelperPlugin.install = function (Vue, options = {}) {
imageSrc = 'placeholder_video'; imageSrc = 'placeholder_video';
break; break;
case 'url': case 'url':
imageSrc = 'url'; imageSrc = 'placeholder_url';
break; break;
case 'application/pdf': case 'application/pdf':
imageSrc = 'placeholder_pdf'; imageSrc = 'placeholder_pdf';

View File

@ -79,17 +79,21 @@
:size="178" :size="178"
:file="{ :file="{
media_type: 'image', media_type: 'image',
thumbnails: { 'tainacan-medium': [ $thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_type) ] }, thumbnails: { 'tainacan-medium': [ $thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_mimetype) ] },
title: $i18n.get('label_thumbnail'), title: $i18n.get('label_thumbnail'),
description: `<img alt='` + $i18n.get('label_thumbnail') + `' src='` + $thumbHelper.getSrc(item['thumbnail'], 'full', item.document_type) + `'/>` description: `<img alt='` + $i18n.get('label_thumbnail') + `' src='` + $thumbHelper.getSrc(item['thumbnail'], 'full', item.document_mimetype) + `'/>`
}"/> }"/>
<figure <figure
v-if="item.thumbnail == undefined || ((item.thumbnail.medium == undefined || item.thumbnail.medium == false) && (item.thumbnail['tainacan-medium'] == undefined || item.thumbnail['tainacan-medium'] == false))" v-if="item.thumbnail == undefined || ((item.thumbnail.medium == undefined || item.thumbnail.medium == false) && (item.thumbnail['tainacan-medium'] == undefined || item.thumbnail['tainacan-medium'] == false))"
class="image"> class="image">
<span class="image-placeholder">{{ $i18n.get('label_empty_thumbnail') }}</span> <span
v-if="item.document_type == 'empty'"
class="image-placeholder">
{{ $i18n.get('label_empty_thumbnail') }}
</span>
<img <img
:alt="$i18n.get('label_thumbnail')" :alt="$i18n.get('label_thumbnail')"
:src="$thumbHelper.getEmptyThumbnailPlaceholder(item.document_type)"> :src="$thumbHelper.getEmptyThumbnailPlaceholder(item.document_mimetype)">
</figure> </figure>
</div> </div>
<br> <br>
@ -383,7 +387,7 @@
this.fetchItem({ this.fetchItem({
itemId: this.itemId, itemId: this.itemId,
contextEdit: true, contextEdit: true,
fetchOnly: 'title,thumbnail,status,modification_date,document_type,document,comment_status,document_as_html' fetchOnly: 'title,thumbnail,status,modification_date,document_type,document_mimetype,document,comment_status,document_as_html'
}) })
.then((resp) => { .then((resp) => {
resp.request.then((item) => { resp.request.then((item) => {

View File

@ -73,12 +73,12 @@
<div class="media"> <div class="media">
<div <div
v-if="!shouldHideItemsThumbnail" v-if="!shouldHideItemsThumbnail"
:style="{ backgroundImage: 'url(' + $thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_type) + ')' }" :style="{ backgroundImage: 'url(' + $thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_mimetype) + ')' }"
class="card-thumbnail"> class="card-thumbnail">
<img <img
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')" :alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
v-if="item.thumbnail != undefined" v-if="item.thumbnail != undefined"
:src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_type)"> :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_mimetype)">
</div> </div>
<div class="skeleton"/> <div class="skeleton"/>

View File

@ -80,7 +80,7 @@
v-if="item.thumbnail != undefined"> v-if="item.thumbnail != undefined">
<img <img
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')" :alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
:src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_type)"> :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)">
</div> </div>
<div class="list-metadata media-body"> <div class="list-metadata media-body">
<span <span

View File

@ -72,8 +72,8 @@
:width="$thumbHelper.getWidth(item['thumbnail'], 'tainacan-medium-full', 120)" :width="$thumbHelper.getWidth(item['thumbnail'], 'tainacan-medium-full', 120)"
:height="$thumbHelper.getHeight(item['thumbnail'], 'tainacan-medium-full', 120)" :height="$thumbHelper.getHeight(item['thumbnail'], 'tainacan-medium-full', 120)"
:hash="$thumbHelper.getBlurhashString(item['thumbnail'], 'tainacan-medium-full')" :hash="$thumbHelper.getBlurhashString(item['thumbnail'], 'tainacan-medium-full')"
:src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_type)" :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)"
:srcset="$thumbHelper.getSrcSet(item['thumbnail'], 'tainacan-medium-full', item.document_type)" :srcset="$thumbHelper.getSrcSet(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)"
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')" :alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
:transition-duration="500" :transition-duration="500"
/> />

View File

@ -87,7 +87,7 @@
v-if="item.thumbnail != undefined"> v-if="item.thumbnail != undefined">
<img <img
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')" :alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
:src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_type)"> :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)">
<div <div
:style="{ :style="{
minHeight: getItemImageHeight(item['thumbnail']['tainacan-medium-full'] ? item['thumbnail']['tainacan-medium-full'][1] : (item['thumbnail'].medium_large ? item['thumbnail'].medium_large[1] : 120), item['thumbnail']['tainacan-medium-full'] ? item['thumbnail']['tainacan-medium-full'][2] : (item['thumbnail'].medium_large ? item['thumbnail'].medium_large[2] : 120)) + 'px', minHeight: getItemImageHeight(item['thumbnail']['tainacan-medium-full'] ? item['thumbnail']['tainacan-medium-full'][1] : (item['thumbnail'].medium_large ? item['thumbnail'].medium_large[1] : 120), item['thumbnail']['tainacan-medium-full'] ? item['thumbnail']['tainacan-medium-full'][2] : (item['thumbnail'].medium_large ? item['thumbnail'].medium_large[2] : 120)) + 'px',

View File

@ -158,7 +158,7 @@
<p>{{ $i18n.get('label_document_empty') }}</p> <p>{{ $i18n.get('label_document_empty') }}</p>
<img <img
:alt="$i18n.get('label_document_empty')" :alt="$i18n.get('label_document_empty')"
:src="$thumbHelper.getEmptyThumbnailPlaceholder(item.document_type)"> :src="$thumbHelper.getEmptyThumbnailPlaceholder(item.document_mimetype)">
</div> </div>
</div> </div>
</transition> </transition>
@ -452,7 +452,7 @@ export default {
<img <img
alt="` + (slideItem['thumbnail_alt'] ? slideItem['thumbnail_alt'] : (self.$i18n.get('label_thumbnail') + ': ' + slideItem.title) ) + `" alt="` + (slideItem['thumbnail_alt'] ? slideItem['thumbnail_alt'] : (self.$i18n.get('label_thumbnail') + ': ' + slideItem.title) ) + `"
class="thumbnail" class="thumbnail"
src="` + self.$thumbHelper.getSrc(slideItem['thumbnail'], 'tainacan-medium', slideItem.document_type) + `"> src="` + self.$thumbHelper.getSrc(slideItem['thumbnail'], 'tainacan-medium', slideItem.document_mimetype) + `">
</div>`; </div>`;
}, },
addSlidesBefore: 2, addSlidesBefore: 2,

View File

@ -172,7 +172,7 @@
<img <img
:alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')" :alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')"
class="table-thumb" class="table-thumb"
:src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_type)"> :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_mimetype)">
<div class="skeleton"/> <div class="skeleton"/>
</span> </span>
</a> </a>