Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit db3aedc

Browse files
committed
Removed the "import" prefix in image path
1 parent 3c63dfc commit db3aedc

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ By the time you read this there might be others. Consult [the documentation](htt
4141

4242
### A note regarding images
4343

44-
Only the featured image will be downloaded. Multiple featured images, images added with ACF and other plugins, are not downloaded. Featured images will be downloaded to the "assets" container into a folder called "imports/{collection_handle}", and saved on a field on the entry called "featured_image".
44+
Only the featured image will be downloaded. Multiple featured images, images added with ACF and other plugins, are not downloaded. Featured images will be downloaded to the "assets" container into a folder called "{collection_handle}/{entry_slug}", and saved on a field on the entry called "featured_image".
4545

4646
You can use the events above to do your own downloading of images and what not. I have done this myself with great success 👍
4747

src/Helpers/Migrator.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private function createEntries()
181181
]));
182182

183183
if (config('statamic-wp-import.download_images')) {
184-
$asset = $this->downloadAsset($meta['data']['featured_image_url'] ?? '', $collection);
184+
$asset = $this->downloadAsset($meta['data']['featured_image_url'] ?? '', $collection, $slug);
185185

186186
if ($asset) {
187187
$entry->set('featured_image', $asset->path());
@@ -220,7 +220,7 @@ private function createPages()
220220
]));
221221

222222
if (config('statamic-wp-import.download_images')) {
223-
$asset = $this->downloadAsset($meta['data']['featured_image_url'] ?? '', 'pages');
223+
$asset = $this->downloadAsset($meta['data']['featured_image_url'] ?? '', 'pages', $slug);
224224

225225
if ($asset) {
226226
$page->set('featured_image', $asset->path());
@@ -237,7 +237,7 @@ private function createPages()
237237
* @param string|null $url
238238
* @return Asset|bool
239239
*/
240-
private function downloadAsset(string $url = null, string $container): Asset|bool
240+
private function downloadAsset(string $url = null, string $collection, string $slug): Asset|bool
241241
{
242242
if (!$url) {
243243
return false;
@@ -251,7 +251,7 @@ private function downloadAsset(string $url = null, string $container): Asset|boo
251251

252252
$assetContainer = AssetContainer::findByHandle('assets');
253253

254-
$asset = $assetContainer->makeAsset("imports/{$container}/{$originalImageName}")
254+
$asset = $assetContainer->makeAsset("{$collection}/{$slug}/{$originalImageName}")
255255
->upload(
256256
new UploadedFile(
257257
Storage::path($tempFile),

0 commit comments

Comments
 (0)