LPS-38276 Make image name last parameter of preview url for download

im still not completely sure about the block *else if (pathArray.length == 3)*
what do you think?
the other changes were made by looking at LPS-24743 when the uuid was added to the url and then making it match the pattern of having the file name last