Should I consider an image path with or without the «pub» prefix?

If you need to get the filesystem path for a media resource, then follow the article How to get an absolute media (image) path programmatically by a relative path.