BOA image file paths

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Juc1's picture

Hi all,

Taking omega8.cc as an example of a BOA site if I click on the logo the path is https://omega8.cc/sites/omega8.cc/files/bigpicture_logo.png

Is this path written to the database and if so does this mean that images will fail to load if the site is copied to another platform ie where the site "omega8.cc" does not exist (and so the path is broken)?

This url https://omega8.cc/files/bigpicture_logo.png also works so why does the logo use https://omega8.cc/sites/omega8.cc/files/bigpicture_logo.png rather than https://omega8.cc/files/bigpicture_logo.png ?

Is there a way to make sure that my BOA sites use the format https://omega8.cc/files/bigpicture_logo.png rather than https://omega8.cc/sites/omega8.cc/files/bigpicture_logo.png in order to avoid problems with broken image paths when copying the site elsewhere?

Thanks...

Comments

Yes, the paths are written to

jtbayly's picture

Yes, the paths are written to the database. However, the migration process actually fixes paths like that if the site URL or directory has changed. It just works. So I don't know if there is a way to force the use of the shorter URL. Unless there is some other reason you want that, you don't need to worry about it.

-Joseph

@ jtbayly ok thanks. Some of

Juc1's picture

@ jtbayly ok thanks.

Some of my BOA sites seem to use the short format image path ie https://omega8.cc/files/bigpicture_logo.png rather than the long format ie https://omega8.cc/sites/omega8.cc/files/bigpicture_logo.png so I wonder what is causing this difference.

Anyway the problem occurs if I export a database from one BOA site (which uses long format image file paths) and then import it to another BOA site on another server (for example if I want to move servers). There is no BOA migration here to correct the image file paths and so on the new site all the image file paths are broken.

I've run into that too. You

jtbayly's picture

I've run into that too. You can still solve it easily, fortunately. Just do a simple migration (staying on the same platform) to a different URL and then back to the URL you actually want.

Hope that helps.

-Joseph

@ jtbayly ok thanks so here

Juc1's picture

@ jtbayly ok thanks so here is what I did to correct the image file paths -

On the old server, clone the site to the new server domain. The domain will not load for DNS reasons but it will exist ok as an Aegir site.
Export the database in Chive / SSH.
Create the site with matching domain on the new server.
Import the database.

Anyway I am still interested in this:

If I add an image in wysiwyg as /files/images/map.png why do some BOA sites turn this into the long image file format... example.com/sites/example.com/files/images/map.png
and other BOA sites use the short format...
example.com/files/images/map.png

...and is it possible for me to tell my BOA sites to stick the short format and avoid using the long format?

It will reference even if you leave out the files

geoff's picture

When I am hard coding image paths, knowing that I may clone or migrate the site to many different names to test versions, I use the relative path above files.

eg <img src="/images/footer/map.png">

This is in the /sites/domain.com/files/images/footer folder.

And it even works.

@ geoff yes I should have

Juc1's picture

@ geoff yes I should have said that I use the relative path for example
<img src="/files/images/map.png">

which I think should work on any BOA site (eg importing a database) but the BOA system seems to amend this path to the format https://example.com/sites/example.com/files/images/map.png ie introducing a specific site example.com to the path.

in regards to relative image urls

Lowell's picture

It is nice to be able to use relative paths when hardcoding image path-names, for example in a wysiwyg. But it is important to know why this works and what limitations it may present.

I believe it works by custom nginx location directives provided by BOA. As long as you are on a server that is rewriting these paths with the directives you are ok. But if you try to move your site to another server without these rewrites your images will be broken and you will need to either include these rewrite directives or add the omitted path folders to your image path records.

Hope this helps with understanding what is going on and with fixing related problems as they arise.

BOA

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: