[IMPLEMENTED] Reference assets by slug

I have changed the Squidex server and restored the backup on a new server. All image urls are NOT found.
Please let me know how to fix it?

How have you restored the backup? With MongoDB or with the backup system? Have you changed the url?

I restored via Mongodb but it did not work, content was gone.

Then I restored via Squidex and it worked. The Urls are same and app name is same in Squidex.

I am getting 404 page for images. For example: https://cms.mysite.io/api/assets/81ca64b8-000f-47ea-a443-922f419ec9fc

Right now, the integrated restore system assigns new ids to all items, because it can also be used to clone an app. I should probably extend the asset api to reference assets by their name.

What is the problem with mongo restore? Have you backed up both databases?

1 Like

Honestly, I have not spent much time with Mongo restore as I thought that it does not include assets. I tried it once and focused on Squidex restore.

I would really give it “+100” votes to link assets by their seo-friendly names. That is common practice with all major systems and it also makes assets to be easily findable in Google images. Plus if we want to share the images via links, they will have meaningful names for tech/non-tech people. I can imagine many more benfits of meaningful links.

To deal with duplicate asset names, may be just add a random short string to the end of duplicate image to make it unique. For example: If assets contain an image “apple-logo.jpg” and we reupload with same name, the next one could be “apple-logo-XtRf4.jpg”

You can also store the assets in MongoDB with the GridFS provider. I will see what I can do with better names. With the current architecture many things are super easy but this one is actually more complicated.

1 Like

Thanks for quick response and looking into it. Will eagerly wait for a better solution.

This CMS is amazing, just need tiny little improvements.

As a workaround I can extend the API to fetch assets by their name as well, but then it would be up to you to ensure that the names for the needed assets are unique.

1 Like

Yes that will do for now. It will be way better than ids.

As an idea. There could be simply an additional field called urlName. Which will be by default same as the filename. But it could be editable by user (similar to editing tags). So incase they are not uniqie for any files. We can edit on our own.

From the Api, we could fetch by id or urlname.

I have used other CMS systems which do the same thing. For example Sitefinity. The only difference is that Sitefinity make sures that urls are unique. But we can take care of it manually for now.

My idea was to just auto generate the slugs for now and then extend the UI in step 2

I pushed a version that just does it.

1 Like

Wow great!! Amazing quick work. thank you for doing that.

Please let me know how to access an image via URL?
I have got latest Docker image and tried https://cms.mysite.io/api/assets/image-slug.jpg.
The slug I imagine is the name of the asset appearing in Squidex Dashboard?

OK. Got it when I looked into Mongodb. The difference was filename had some uppercase letters.

Thanks again for the changes. :slight_smile:

For the UI changes:
I just tried to edit the filename in UI and it does change the filename and slug both in db which is good.
For later may be, the only little change we might need is a link with slug on hover (similar to current link in download icon).

I tend to switch to a dialog instead. We also have a 3 fields and more could come in the future.

1 Like

totally fine. thank you!!

I added the dialog, but the build is still running, so I am not sure if everything is fine. But you can check it here and then add then test it out if you want: https://build.squidex.io/Squidex/squidex/

1 Like