Randomly disappearing images in repeater

Hi,

I’m having an embarrassing problem, or bug, which I don’t understand quite well and I was wondering if it was something I didn’t understand properly, or if it could be a bug.

I have this Tailor blueprint, Site\Page, which contains, well, the site’s pages. Each page is a structured entry that has building blocks in the form of a builder repeater. I have blocks such as “Hero”, “SlideShow”, “ParagraphBlock” and so on, with their own fields and my content has partials to deal with them based on the type of block to render on said page.

Problem is, sometimes, (I’m not sur what triggers it yet), when I browse my site, some images disappear! I rush to the backend, find the right record and the image is empty. I even went to the database and of course, the JSON for it is empty (image:""). I’m not sure if it has to do with the multisite editing switching or what, and I can’t really figure out what I do to trigger it, but I would like to know if someone else has experienced this and if they found out what it was.

Did this ever happened to you and did you find out what was causing it?

Thanks in advance for your consideration and help.

Ok, got it (again).

It appears that a colleague was subtilty cleaning up the Medias and altered the name of some folders in there (e.g. “Page Home” to “Page - Home”). So for a moment there, the data in the database was pointing to the old name, hence the image not showing up on the site, but it was still there. However, when we went to the backend, of course, the image wasn’t showing up, and if we modified anything in the record, it would just erase the image string entirely since it was invalid anyway.

So. Has it been suggested somewhere to introduce a mechanism to point to files in the Media Finder indirectly instead of relying on a string path?

I mean, moving things around currently will always break something, and it can be difficult to try and find out all the references by hand. The string could represent a kind of a permalink to the actual physical file. Ok, I know, the media is an actual physical directory (storage/app/media) which can be modified externally which would make it complicated to monitor and keep the permalink pointing at the right file.

Any thoughts on how this could be addressed?

I though maybe we could start with a command like php artisan media:audit which would scan every “mediafinder” type fields and check if the value points to a valid image or not, reporting the bad links.

Or maybe we could have a command like php artisan media:relink to update the permalinks (stored somewhere) when changes are made outside of the media finder so the already created permalinks are correctly updated.

Also, maybe the backend could realize that a file is missing and highlight the field while showing the current file name, making easier to find the new one and correct it.

Thanks for your ideas and help!

There’s an event triggered after a folder is moved:

https://octobercms.com/docs/api/media/folder/move

There’s an event triggered after a folder is renamed:

https://octobercms.com/docs/api/media/folder/rename

I did have to use that in order to update links so that they don’t get break.

You have good ideas above.

1 Like

Thank you for these informations, @apinard.

This means that I could create a plugin to catch these events and update the mediafinder fields in my theme accordingly. That could work.

I still think that there should be a way for Tailor blueprints to respond to these events and automatically update mediafinder fields by itself, however. My theme does not have a plugin (yet) and I don’t think everyone using Tailor should create one either for the sole purpose of updating mediafinder fields.

But with the information you provided, I see a possibility here to suggest an viable improvement!

Thanks!

1 Like