There's a similar question here, but it concerns D6 or D7. It seems to me the suggested solution won't work in Drupal 8 for two reasons:
- It's very unadvisable to attack the database directly with SQL, you should be using Entity queries and the API
- As of D8, inline images become managed files, and are referenced as being attached to the nodes in which they appear - another reason for using the API.
I'm in the middle of writing a Drush command whose purpose is to go through all the inline images migrated from an existing (D6) site, detect them, enter them into the system as managed files, and attach them to their nodes. Looking at the file_managed table in the database, I see that the file URI is always public://something.jpg
(for example), so that if you add an inline image via CKEditor then (with the default settings) it will be public://inline-images/mypicture.jpg
(for example).
Well that seemed to me very cool, because it protects you from changes in the public files settings (for example, if you're building a site with shared code for multiple domains and the public files folders will change when it goes into production). So I started trying out using a URI in body text something like this: <img src="public://cwg.jpg" />
But this doesn't work: the image doesn't show up and if I try saving it, the "public" gets removed so that it looks like this: <img src="//cwg.jpg" />
.
When I enter an inline image through CKEditor in the normal way, I get something like this:
<img alt="" data-entity-type="file" data-entity-uuid="f80852d8-af54-45f8-9c4e-7a2c2196fee5" src="/sites/d822.dd/files/inline-images/cwg.jpeg">
Is there any way of persuading the inline images to use "public://"? Or should I be looking at the Media Entity module (which I wanted to avoid, because it's overkill for my requirements)