Skip to content

Commit f805830

Browse files
committed
Remove AdobeStockImageAdminUi Hard Dependency + fix to UpdateAdminImage
1 parent 87c0210 commit f805830

2 files changed

Lines changed: 15 additions & 21 deletions

File tree

Controller/Adminhtml/Ajax/UpdateAdminImage.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,23 @@ public function execute()
107107
}
108108

109109
$cleanUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . $parsedUrl['path'];
110-
$baseUrl = $this->storeManager->getStore()->getBaseUrl();
111-
$relativePath = str_replace($baseUrl, '', $cleanUrl);
112-
$relativePath = ltrim($relativePath, '/');
110+
111+
// Derive the relative path from the URL path component directly — the admin
112+
// store's base URL doesn't always match the public storefront URL used by the
113+
// media gallery, so str_replace($baseUrl, ...) can leave the host in the path.
114+
$relativePath = ltrim($parsedUrl['path'], '/');
115+
116+
// Strip leading `pub/` when Magento is served from <docroot>/pub/.
117+
$relativePath = preg_replace('#^pub/#', '', $relativePath);
118+
119+
// Strip the `.renditions/` segment so Cloudinary fetches the original image
120+
// instead of the local PageBuilder/admin-gallery rendition derivative, which
121+
// 404s through the auto-upload mapping (mapping points at the original path).
122+
$relativePath = preg_replace('#(^|/)\.renditions/#', '$1', $relativePath);
123+
$cleanUrl = preg_replace('#/\.renditions/#', '/', $cleanUrl);
113124

114125
// Create Image object and use UrlGenerator (same as storefront)
115-
$image = Image::fromPath($remoteImageUrl, $relativePath);
126+
$image = Image::fromPath($cleanUrl, $relativePath);
116127

117128
// Use UrlGenerator which handles all the logic including database mapping
118129
$cloudinaryUrl = $this->urlGenerator->generateFor($image, $this->transformation);

view/adminhtml/ui_component/media_gallery_listing.xml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,4 @@
2323
<dep>media_gallery_listing.media_gallery_listing_data_source</dep>
2424
</deps>
2525
</settings>
26-
<columns name="media_gallery_columns">
27-
<column sortOrder="1" name="overlay" component="Magento_Ui/js/grid/columns/overlay" class="Magento\AdobeStockImageAdminUi\Ui\Component\Listing\Columns\UnlicensedOverlay">
28-
<settings>
29-
<label translate="true">Overlay</label>
30-
<visible>true</visible>
31-
<sortable>false</sortable>
32-
</settings>
33-
</column>
34-
<column name="thumbnail_url" component="Magento_AdobeStockImageAdminUi/js/mediaGallery/grid/columns/licenseImage">
35-
<argument name="data" xsi:type="array">
36-
<item name="config" xsi:type="array">
37-
<item name="imageDetailsurl" xsi:type="url" path="media_gallery/image/details"/>
38-
<item name="imageComponent" xsi:type="string">adobe_stock_images_listing.adobe_stock_images_listing.adobe_stock_images_columns.preview</item>
39-
</item>
40-
</argument>
41-
</column>
42-
</columns>
4326
</listing>

0 commit comments

Comments
 (0)