I would like to redirect the url of my images from my previous website to the new url in my wix site.
But I would like to do that automatically (too much images)…through a router hook or something like that I think I can implement it or at least detect the format of my old url like https://www.mydoamain.com/images/root/subfolder/myimage.jpg, and then redirect to the new url from my wix site.
Thus, I uploaded all my old images to the wix media manager, keeping the same folder structure:
/legacy/ root/subfolder/myimage.jpg .
All I have to do is extract the image path, i.e. root/subfolder/myimage.jpg, from the requested url, and find the wix url for the corresponding image in the media manager, located in /legacy/ root/subfolder/myimage.jpg
And here I really don’t know how to do that…
I need to find a wix image Url from the path in the media manager…
Does anybody know how to do that?
Thanks a lot in advance.
Thanks for the response, but I don’t think it will help me…
Since I just want to query the media manager to get an image URI from a path on backend side (router hook), I don’t use any “Image” element, and anyway, the Image element does not allow to get the info I’m searching for.
Thanks anyway
@davidguillemet
Isn’t this what you are searching for? …
This example path ???
wix:image://v1/57da6c_80872dcb64e5460ba0dbf18b6b172085~mv2.jpg/Avatar.jpg#originWidth=1000&originHeight=750
If YES, then take a look here…
@russian-dima Not really…
I need the HTTP Url, not the Wix URL, but in fact, the most important problem here is not what to get but rather how to get it, just from the information I have.
Let me rephrase the problem…
Before switching to wix, my website was implemented on Joomla.
I had hundreds of pictures which were accessible through a simple HTTP Url like http://www.mysite.com/images/folder1/folder2/image.jpg
Now, my domain has been transferred to wix and of course, the response for the Url above is a nice 404, since you cannot access image this way with wix, so far.
The first solution is to create 301 redirections, but I would need to do that for each single image from http://www.mysite.com/images/folder1/folder2/image.jpg to something like
https://static.wixstatic.com/media/e50527_fa26dd116fdf4bf08a5d8fac30f9dc14~mv2.jpg
You can imagine it is not conceivable.
Then, the second idea would be to use a router hook, like beforeRouter - or something like that - then catch the url like /images/folder1/folder2/image.jpg , extract the path from the query string (i.e. folder1 > folder2 > image.jpg), and ask the media manager for the image HTTP Url based on this path.
Knowing I have uploaded all my images in the same folder structure in the media manager as in my legacy joomla web site.
But it appears, the getFileUrl() API takes only the file name as input parameter, but not the original name as “image.jpg”, but rather the wix name as " e50527_fa26dd116fdf4bf08a5d8fac30f9dc14~mv2.jpg "
Thus, I really don’t know how to map my file path to an http url…
unless I missed something…
But if someone from wix team reads this, would it be possible to improve the media manager API to get a file URL from its path?
Or just let a request like http://www.mysite.com/images/folder1/folder2/image.jpg render the corresponding image knowing it is located in “/images/folder1/folder2” in the media manager?
@davidguillemet
I would try to help you, but at moment i am a little bit overloaded
Any answer on this? I also need to retrieve image URL with code.
I know it’s possible to get it through the Media Manager, but I need to automate the process through code.
I’d highly appreciate a response on this, thanks.
Ok I got it here is how it works:
Image source (from media manager):
wix:image://v1//#originWidth=width&originHeight=height
And from the media manager we can copy the URL, which would be the following:
https://static.wixstatic.com/media/< uri>
Works like a charm.
Hope it helps.
Hi, unfortunately it’s not really what I’m looking for…
I know how this works, but in my case, I would need to get an image url from its path in the media manager:
Imagine you uploaded image.jpg in the media manager, in the following folder:
/legacy/folder1/folder2/
And then, I would need to get the image url, i.e. something like https://static.wixstatic.com/media/e50527_fa26dd116fdf4bf08a5d8fac30f9dc14~mv2.jpg , from the image path, i.e. /legacy/folder1/folder2/image.jpg
In the media manager when you roll over an image you’ll see an icon with an ellipsis “…” on the upper right corner. Click on it and and you’ll see “Copy URL”. Click on that and the image URL will be copied to your computer’s clipboard/memory and you’ll be able to paste it anywhere
at the point.
Yes we get it, we can get it manually but we need to get it PROGRAMATICALLY
Hi all, I just implemented a kind of workaround based on:
- a new collection containing my legacy images as one gallery per row
- a group redirect
- an http function that:
- queries the collection
- redirects to a wix media url
It is working fine and my legacy images http://www.mysite.com/images/folder1/folder2/image.jpg are redirected to a new wix media url https://static.wixstatic.com/media/e50527_fa26dd116fdf4bf08a5d8fac30f9dc14~mv2.jpg as expected.
But I still have an issue with an HTTP 429 error: too many requests
For example, my legacy images were referenced from a photography forum where I inserted many links to my images in a single thread.
Then, when I display the page, tens of requests are sent to my wix http function, each call requesting the collection.
Only a few (less than 5) images are displayed on the page and I get the error 429 for all the others.
If I remove the collection query in the http-function (query result is hard coded), a bit more images are displayed, but I still have the 429 error.
Does anybody know how to get rid of this limitation and allow many htt-function calls being served in the same time?
Or is there a way to make wix working as a real image server?
It was so simple with my previous joomla site…
Thanks a lot in advance.
Well done mate!
When i hear “real” the first what comes into my mind…
https://www.wix.com/velo/reference/wix-realtime
Yes. I need this too. I have uploaded hundreds of images into Media. I have a collection that has a row for each image. The row includes a field containing the image file name. But to display it in Wix I need the url. There are too many to copy them manually. Is there not a simple way to get the url from the file name programatically?
Did you find a solution? I need to display images that are specific to a user. I need to store the URL on the database.
@lmdbluis Did you find out how? I also need this feature in 2022.
Hi yes this is possible,
Assuming this is the type of url you get from Wix:
"wix:image://v1/656460_7c0826fb3aed4d3f8dd0e39ddcae0ab6~mv2.png"
You can use the code below:
"https://static.wixstatic.com/media/" + imageSrc.split("/")[3] + "/v1/fill/w_128,h_128,al_c/" + ImageTitle + ".png "
And that would convert it to something like this:
"https://static.wixstatic.com/media/656460_7c0826fb3aed4d3f8dd0e39ddcae0ab6~mv2.png/v1/fill/w_128,h_128,al_c/ImageTitle.png"
IMPORTANT NOTE:
-
ImageSrc = The original WIX image Src
-
ImageTitle = The title or alt text that will display as the browser title
-
If the images you are passing doesn’t have a fixed width and height, Your only option is to change the fill to fit. Then you can set the image quality by adjusting the width and height. So this:
"https://static.wixstatic.com/media/" + imageSrc.split("/")[3] + "/v1/fit/w_128,h_128,al_c/" + ImageTitle + ".png "
- If you’re still having problem with how the image is being displayed, you can remove the effect but at a cost of your ability to change the image title. So this:
"https://static.wixstatic.com/media/" + imageSrc.split("/")[3]
Your welcome,
DJ bon26