File tree Expand file tree Collapse file tree 4 files changed +103
-0
lines changed
MediaGalleryUi/Ui/Component/Listing/Columns Expand file tree Collapse file tree 4 files changed +103
-0
lines changed Original file line number Diff line number Diff line change @@ -102,4 +102,25 @@ public function beforeResizeFile(
102102 }
103103 return [$ source , $ keepRatio ];
104104 }
105+
106+ /**
107+ * @param \Magento\Cms\Model\Wysiwyg\Images\Storage $subject
108+ * @param \Closure $proceed
109+ * @param $source
110+ * @param $keepRatio
111+ * @return mixed
112+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
113+ */
114+ public function aroundResizeFile (
115+ \Magento \Cms \Model \Wysiwyg \Images \Storage $ subject ,
116+ \Closure $ proceed ,
117+ $ source ,
118+ $ keepRatio = true
119+ ) {
120+ if (pathinfo ($ source , PATHINFO_EXTENSION ) == 'pdf ' ) {
121+ return $ source ;
122+ }
123+
124+ return $ proceed ($ source , $ keepRatio );
125+ }
105126}
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Copyright © All rights reserved.
4+ * See COPYING.txt for license details.
5+ */
6+ declare (strict_types=1 );
7+
8+ namespace Experius \WysiwygDownloads \Plugin \Magento \MediaGalleryUi \Ui \Component \Listing \Columns ;
9+
10+ use Magento \Framework \Filesystem ;
11+ use Magento \Store \Model \StoreManagerInterface ;
12+ use Experius \Core \Helper \Settings ;
13+
14+ class Url
15+ {
16+
17+ /**
18+ * @param Filesystem $filesystem
19+ * @param StoreManagerInterface $storeManager
20+ * @param Settings $helperSettings
21+ */
22+ public function __construct (
23+ public Filesystem $ filesystem ,
24+ public StoreManagerInterface $ storeManager ,
25+ public Settings $ helperSettings
26+ ) {}
27+
28+ /**
29+ * @param \Magento\MediaGalleryUi\Ui\Component\Listing\Columns\Url $subject
30+ * @param $result
31+ * @return mixed
32+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
33+ */
34+ public function afterPrepareDataSource (
35+ \Magento \MediaGalleryUi \Ui \Component \Listing \Columns \Url $ subject ,
36+ $ result
37+ ) {
38+ if (!$ this ->helperSettings ->getConfigValue ('system/media_gallery/enabled ' )) {
39+ return $ result ;
40+ }
41+
42+ foreach ($ result ['data ' ]['items ' ] as &$ item ) {
43+ if ($ item ['content_type ' ] == "PDF " ) {
44+ $ item ['thumbnail_url ' ] =
45+ $ this ->storeManager ->getStore ()->getBaseUrl (\Magento \Framework \UrlInterface::URL_TYPE_MEDIA )
46+ . 'pdf-icon.png ' ;
47+ }
48+ }
49+
50+ return $ result ;
51+ }
52+ }
Original file line number Diff line number Diff line change 6767 sortOrder =" 10" />
6868 </type >
6969 <preference for =" Magento\Framework\Image\Adapter\Gd2" type =" Experius\WysiwygDownloads\Image\Adapter\Gd2" />
70+ <type name =" Magento\MediaGalleryIntegration\Plugin\SaveImageInformation" >
71+ <arguments >
72+ <argument name =" imageExtensions" xsi : type =" array" >
73+ <item name =" pdf" xsi : type =" string" >pdf</item >
74+ </argument >
75+ </arguments >
76+ </type >
77+ <type name =" Magento\MediaGalleryRenditions\Model\Queue\FetchRenditionPathsBatches" >
78+ <arguments >
79+ <argument name =" fileExtensions" xsi : type =" array" >
80+ <item name =" pdf" xsi : type =" string" >pdf</item >
81+ </argument >
82+ </arguments >
83+ </type >
7084</config >
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" ?>
2+ <config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:ObjectManager/etc/config.xsd" >
3+ <type name =" Magento\MediaGallerySynchronization\Model\FetchMediaStorageFileBatches" >
4+ <arguments >
5+ <argument name =" fileExtensions" xsi : type =" array" >
6+ <item name =" pdf" xsi : type =" string" >pdf</item >
7+ </argument >
8+ </arguments >
9+ </type >
10+ <type name =" Magento\MediaGalleryUi\Ui\Component\Listing\Columns\Url" >
11+ <plugin name =" Experius_WysiwygDownloads_Plugin_Magento_MediaGalleryUi_Ui_Component_Listing_Columns_Url" type =" Experius\WysiwygDownloads\Plugin\Magento\MediaGalleryUi\Ui\Component\Listing\Columns\Url" sortOrder =" 10" disabled =" false" />
12+ </type >
13+ <type name =" Magento\Cms\Model\Wysiwyg\Images\Storage" >
14+ <plugin name =" Experius_WysiwygDownloads_Plugin_Magento_Cms_Model_Wysiwyg_Images_Storage" type =" Experius\WysiwygDownloads\Plugin\Magento\Cms\Model\Wysiwyg\Images\Storage" sortOrder =" 10" disabled =" false" />
15+ </type >
16+ </config >
You can’t perform that action at this time.
0 commit comments