Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1010: Image size is not passed to image-uploader when inserting an image from new media gallery #1021

2 changes: 2 additions & 0 deletions MediaGalleryUi/Model/AssetIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function __construct(
* Create MediaGallery asset and save it to database based on file information
*
* @param \SplFileInfo $item
* @throws \Exception
*/
public function execute(\SplFileInfo $item): void
{
Expand All @@ -94,6 +95,7 @@ public function execute(\SplFileInfo $item): void
'updated_at' => (new \DateTime())->setTimestamp($item->getMTime())->format('Y-m-d H:i:s'),
'width' => $width,
'height' => $height,
'size' => $item->getSize(),
'content_type' => 'image/' . $item->getExtension()
]
]
Expand Down
1 change: 1 addition & 0 deletions MediaGalleryUi/Model/UpdateAssetInGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public function execute(AssetInterface $asset): void
'source' => $asset->getSource(),
'width' => $asset->getWidth(),
'height' => $asset->getHeight(),
'size' => $asset->getSize(),
'created_at' => $asset->getCreatedAt(),
'updated_at' => $asset->getUpdatedAt(),
'keywords' => implode(",", $keywords) ?: null
Expand Down
1 change: 1 addition & 0 deletions MediaGalleryUi/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<column xsi:type="varchar" name="name" length="255" nullable="true" comment="Image Name"/>
<column xsi:type="int" name="width" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Width"/>
<column xsi:type="int" name="height" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Height"/>
<column xsi:type="int" name="size" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Size"/>
<column xsi:type="datetime" name="created_at" nullable="true" comment="Uploaded Date"/>
<column xsi:type="datetime" name="updated_at" nullable="true" comment="Modification Date"/>
<column xsi:type="text" name="keywords" nullable="true" comment="Comma separated keywords"/>
Expand Down
1 change: 1 addition & 0 deletions MediaGalleryUi/etc/db_schema_whitelist.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"name": true,
"width": true,
"height": true,
"size": true,
"created_at": true,
"updated_at": true,
"keywords": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ define([
window.MediabrowserUtility.closeDialog();
throw 'Target element not found for content update';
}

targetElement.val(record['thumbnail_url'])
.data('size', record.size)
.data('mime-type', record['content_type'])
.trigger('change');
window.MediabrowserUtility.closeDialog();
Expand Down