Images in a project - relative or absolute paths?

Can anyone confirm if an image file dragged into a project gets a relative or absolute path?

Is there a way to force Xojo to use relative paths so that things continue to work when multiple devs are working on the same code base via GitHub?

Thanks

Steve.

1 Like

In my experience the path is relative to the user. If you have 2 different users then the code must be in the same subpath to the user.

For the project, the link is always absolute.

You can make an alias on your file and copy it into the project.

It is also possible to put this file on a server.

For the compiled version, no problem since this file is copied into the resources.

I can tell you from my experience working with text projects, and from working with Arbed: images are referred to by SaveInfo, FullPath and PartialPath, the latter being the path relative to the project file.

If you move the project, including the images relative to the project, to a different folder, everything should still work.

If you use Save As to save your project into a new location, all the PartialPaths get updated to point to the original image, using ../ to ascend from the new location to the common folder in both the old and new location and then descending again to the original image. No images get saved to the new location, not with binary projects, and not with text projects.

I never observed images added to a project that were not saved in a folder below the project folder. So I don’t know, how those get treated.

The best advice, in my opinion, is to use File > Collect Project Items when preparing your project for git to ensure that everything is copied to a single directory and paths are relative to the project file. Then, if you wish, you can remove the resulting “Plugins” and “Scripts” subdirectories. From that point forward, add any images you wish to use in your project to the images folder created by the IDE and the IDE’s default of using relative paths usually* handles everything correctly

*There have, in the past, been instances of the IDE freaking out a bit and generating invalid paths that look something like ../../../../../../../../../file.png.

If you store your images in the repository the relative paths will be relative to the project and will work.

Anthony’s advice will fix your project if you haven’t been doing that.

Thanks to all who answered on this thread. I’ve passed the information on.

Best regards.

Steve

FWIW, I can still get those in the current Xojo version.