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

Assets aren't assigned correctly if filename is the same #749

Closed
darylknight opened this issue Sep 21, 2020 · 5 comments
Closed

Assets aren't assigned correctly if filename is the same #749

darylknight opened this issue Sep 21, 2020 · 5 comments
Assignees
Labels

Comments

@darylknight
Copy link

darylknight commented Sep 21, 2020

Feel free to update the inaccurate title, I wasn't sure what to call this.

I have a site which imports about 500 entries from a JSON feed. I've recently tried to get it to also import images, and I've realised there's a couple of issues with it.

The URLs for separate entries look like this:

https://steamcdn-a.akamaihd.net/steam/apps/381780/capsule_616x353.jpg
https://steamcdn-a.akamaihd.net/steam/apps/970830/capsule_616x353.jpg
https://steamcdn-a.akamaihd.net/steam/apps/752590/capsule_616x353.jpg
https://steamcdn-a.akamaihd.net/steam/apps/278360/capsule_616x353.jpg

So the image file name is always the same, but the ID in the middle of the URL changes (as you can tell, this is Steam's external URL structure so I can't change it).

These URLs aren't included in Steam by default, I'm writing my own JSON file to overwrite the assets of 500 games already in the CMS.

When I run this import, there are 3 options for 'if exists', either:

  • Use existing asset - This runs the import, but only downloads the FIRST image and assigns it to all 500 entries
  • Replace existing asset - This runs the import, downloads the correct image for each entry, then overwrites that asset in the control panel and assigns it to all entries, leaving me with the same result as above, but with the LAST image imported
  • Keep both: This downloads all images to Assets correctly, but it still just assigns the most recently downloaded image to all entries:

image

Additionally, about 50% of the images it downloads get cut off partway, looks like it's not downloading correctly:

image

Best way I can think of to get around this is to add something to FeedMe that lets you change the name of the asset on import? So something like "import asset from URL and rename to {{ entry.title }}-{{ existingFileName }}.

  • Craft version: 3.5.11
  • PHP version: 7.4.8
  • Database driver & version: MySQL
  • Plugins & versions: FeedMe 4.2.3
@patbrumfield
Copy link

I'm encountering this same issue with regards to assets where the source file has the same filename, but different URL structure. When entries are created via FeedMe, that entries' correct images are imported and added, but the first "set" of images that aren't associated with that entry (just have the same filename, and are from the first entry imported), are also added to the entry.

Has anyone come up with a solution here?

Craft 3.8.14
PHP 8.2.7
FeedMe 4.6.3.1

@gbowne-quickbase
Copy link

If you set the FIELD where the image/asset is going to specify a default upload location that will be different for each entry using it, then feed-me will create a directory as you go along. Since your slugs need to be unique, so will your image directories, and then your images can all have the same name. You'll do this by editing the field and specifying a default upload location. I don't know if you'd be able to use the id in your url but you might? At least slug would be unique
image

@angrybrad
Copy link
Member

Resolved in c78b5a5 and will be included in the next release!

@patbrumfield
Copy link

patbrumfield commented Nov 25, 2023 via email

@juddlyon
Copy link

juddlyon commented Dec 1, 2023

Thank you @i-just & @angrybrad!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants