Problem/Motivation
According to instructions of comments in settings.php, a different domain can be set in the public file base URL ($settings['file_public_base_url']), which allows the serving of static files to a CDN service.
After enable that setting, inline images uploaded with CKEditor will have an absolute URL in the src attribute. That works as expected. But with the "Restrict images to this site" filter enabled, all uploaded images will fail to display because their src attributes won't start with $base_path anymore.
Steps to reproduce
- Install Drupal.
- Setup a web server (like nginx or caddy) to handle TLS access to the site's domain, let's say, "https://mysite.com" for example.)
- Setup
$settings['file_public_base_url']to an external domain, let's say "https://files.mysite.com", also setup my web server to serve file from Drupal'sfilesfolder under that domain. - Enable modules like CKEditor, create a text format with CKEditor and inline-images uploads enabled.
- Enable "Restrict images to this site" filter.
- Add an article with inline-images. These images look fine in the CKEditor, but fail to display after I publish the article.
Proposed resolution
While checking function in filter.module checks only whether or not the src attribute starts with $base_path, and whether or not the file is reachable (by running getimagesize()), I think the function should check the src attribute in a detailed manner, to make sure the filter can work with other functions of Drupal like public file base URL (or maybe image styles or so).
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3201331-06.patch | 1.15 KB | hehongbo |
| #2 | identify_public_base_url.patch | 1019 bytes | hehongbo |
Comments
Comment #2
hehongbo commentedCame up with this dirty patch as a workaround, but I don't know if it's a good idea, since this also bypasses the file existence check.
Comment #3
hehongbo commentedComment #4
hehongbo commentedSorry for my bad habits as I'm new in PHP coding/debugging. The namespaced class are referenced with use statements in this one as the CI suggests.
Comment #5
hehongbo commentedComment #6
hehongbo commentedComment #8
hehongbo commentedComment #13
socialnicheguru commentedWhen installing a site and even some modules i get this: Passing null to parameter #1 ($string) of type string is deprecated filter.module
The variable is not set yet on install:
Drupal 10.4.8
php8.3