Relative paths for local images #919

Open
opened 2026-02-04 22:55:03 +03:00 by OVERLORD · 11 comments
Owner

Originally created by @jelle82 on GitHub (Nov 21, 2018).

Make the paths to locally stored images relative instead of absolute. For example <img src="/uploads/images/gallery/cat.png" /> instead of <img src="http://bookstack.example.com/uploads/images/gallery/cat.png" />,

It increases portability. f you want to change the domain name for the Bookstack App there is no need to change all the image urls afterwards.

Originally created by @jelle82 on GitHub (Nov 21, 2018). Make the paths to locally stored images relative instead of absolute. For example `<img src="/uploads/images/gallery/cat.png" />` instead of `<img src="http://bookstack.example.com/uploads/images/gallery/cat.png" />`, It increases portability. f you want to change the domain name for the Bookstack App there is no need to change all the image urls afterwards.
Author
Owner

@Sibbo07 commented on GitHub (Nov 21, 2018):

That would be very helpfull!

@Sibbo07 commented on GitHub (Nov 21, 2018): That would be very helpfull!
Author
Owner

@ssddanbrown commented on GitHub (Nov 22, 2018):

This would be nice but will make the logic more complex.
Was a while ago but I think i decided to use full paths since we'd have to handle full paths anyway for external storage systems (S3). Easier to standardise on one format.

@ssddanbrown commented on GitHub (Nov 22, 2018): This would be nice but will make the logic more complex. Was a while ago but I think i decided to use full paths since we'd have to handle full paths anyway for external storage systems (S3). Easier to standardise on one format.
Author
Owner

@andreicocari commented on GitHub (Jan 15, 2019):

Would it make sense in that case to have a "base domain" field in the Settings page? I believe Wordpress has a similar approach.

@andreicocari commented on GitHub (Jan 15, 2019): Would it make sense in that case to have a "base domain" field in the Settings page? I believe Wordpress has a similar approach.
Author
Owner

@ssddanbrown commented on GitHub (Jan 15, 2019):

@andreicocari Yeah, Although we essentially already have this via APP_URL in the .env file.

@ssddanbrown commented on GitHub (Jan 15, 2019): @andreicocari Yeah, Although we essentially already have this via `APP_URL` in the `.env` file.
Author
Owner

@recklessnl commented on GitHub (Mar 5, 2019):

+1 for this!

@recklessnl commented on GitHub (Mar 5, 2019): +1 for this!
Author
Owner

@comnam90 commented on GitHub (Mar 14, 2019):

+1 for this, it's needed for environments where the internal and external URLs are different.

@comnam90 commented on GitHub (Mar 14, 2019): +1 for this, it's needed for environments where the internal and external URLs are different.
Author
Owner

@GarethFox commented on GitHub (Mar 25, 2019):

+1 too ^^
I face the same issue using a temporary url to create content and modifying the url when staging to production environment with final url, all the images are not displayed any more, they are referring to the old url in use when uploaded.

@GarethFox commented on GitHub (Mar 25, 2019): +1 too ^^ I face the same issue using a temporary url to create content and modifying the url when staging to production environment with final url, all the images are not displayed any more, they are referring to the old url in use when uploaded.
Author
Owner

@antontkv commented on GitHub (May 19, 2019):

+1
Have the same issue after migrating to another domain.

@antontkv commented on GitHub (May 19, 2019): +1 Have the same issue after migrating to another domain.
Author
Owner

@Stefansen commented on GitHub (Jun 28, 2024):

any update on this issues?

@Stefansen commented on GitHub (Jun 28, 2024): any update on this issues?
Author
Owner

@reingit commented on GitHub (Nov 26, 2025):

I fixed it like this for now:

  1. Backup db: mysqldump bookstack > db.backup.sql
  2. Comment out return 1 for url check in app/Console/Commands/UpdateUrl.php
  3. php artisan bookstack:update-url https://bookstack.non.tor https://bookstack.onion
  4. php artisan bookstack:update-url https://bookstack.onion ""

Havent really tested it much, but everything I needed relative is relative now. Might crontab this in the future.

@reingit commented on GitHub (Nov 26, 2025): I fixed it like this for now: 1) Backup db: mysqldump bookstack > db.backup.sql 2) Comment out return 1 for url check in app/Console/Commands/UpdateUrl.php 3) php artisan bookstack:update-url https://bookstack.non.tor https://bookstack.onion 4) php artisan bookstack:update-url https://bookstack.onion "" Havent really tested it much, but everything I needed relative is relative now. Might crontab this in the future.
Author
Owner

@ssddanbrown commented on GitHub (Nov 27, 2025):

@GarethFox Just be aware that this can mess with some functionality (like references, ZIP export handling) since the base URL is used as an anchor point for parsing/discovery, and it'd make it tricky to change URLs (especially sub-paths) if needed in the future.

@ssddanbrown commented on GitHub (Nov 27, 2025): @GarethFox Just be aware that this can mess with some functionality (like references, ZIP export handling) since the base URL is used as an anchor point for parsing/discovery, and it'd make it tricky to change URLs (especially sub-paths) if needed in the future.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#919