Kirby editor plugin: absolute image path

Hi, I’m testing the recent editor plugin and I adore it!
I only have a big issue regarding the image block, as all the images are stored with the absolute path:

https://siteurl/media/pages/page-a/subpage-a/imagename.jpg

This could be a problem because the site url or the folders can change (actually I have both cases :frowning: ).

Any hint?
Thanks in advance!

Francesco

You can set the site URL in the config, and if use multiple domain based configs, you can use different URLs. But Im not sure that will help here, since once its set in the field, then its recorded.

I think the real fix here is to use a global folder for your images, rather then adding them to the current page, so they are always in the same place. If you set an unlisted page up with a files section in it, and use that as your media library. I think you can pull from there in to the editor (not tottally sure there, it might be a slight tweak to the image block that the editor uses).

But i have to ask - why does the page structrure and site url change alot? Whats the work flow / reasoning?

It will definetely change if you deploy from local to remote.

But I can’t see how this creates a problem. I just test deployed without an issue. The image selected and stored locally renders correctly in the Panel and on the front end. I think the image src is calculated from the media URL or from the other information stored in the block.

You will run into issues if you remove the images, though, after they have been stored.

Use cases (I have all of them):

  • From local to remote (as @texnixe pointed out)
  • From a temporary url to a final url (I’m migrating a 200-articles site to Kirby)
  • I want to feel free to change the URI of the article right before to publish it

I think the issue is moving the pages around, outside of the panel. Then the stored URL needs fixing… but its pretty late and my brain is fuzzy…

Hm, looks like changing the page URL breaks the image.

There is already an issue on GitHub. https://github.com/getkirby/editor/issues/189

You’re right. :frowning: I edited my post.

You might be able to fix it manually with a code editor, doing a global find and replace on the whole project. Look at the field content though, in the code editor, as I think the editor stores stuff with escape characters added. Youll need to mirror that in your find and replace rule.

Yes I could. But it’s pretty bad as a solution…

Agreed, but until the issue is corrected, I think it’s your only option.

The editor plugin is awesome, but it is still pretty new and shiny, so things like this are to be expected until it matures a little more.

I wouldn’t recommend that either, because you would have to repeat that after every change. Let’s wait for a fix, although interestingly in my test in only breaks when changing the page slug, not when deploying to another site url as long as the page structure remains the same.

I found that to be true too… the editor is powering almost this entire page on one of my sites (https://theworkofothers.com/spotlight/davide-pelino) … i built it locally and pushed it live. i hardly ever work on the live domain in the panel, always locally. All the images and videos worked fine.

Thanks. I will try it tomorrow. Anyway, the slug-related issue remains…
Good night!

Ok, I also checked that uploading the page from local to live doesn’t break the images. But the editor doesn’t support any slug change yet. Good to see that @bastianallgeier marked this behaviour as a bug :slight_smile:
Thanks