Answer the question
In order to leave comments, you need to log in
How to write a regular expression to replace image paths on a website?
Greetings.
The site has many images. Images are taken from links from dropbox, yandex.disk and many other image publishing services. I would like to organize all the available images in the site files, and not on third-party resources, but there are problems: there are many images and many different combinations of their paths. Examples:
- downloader.disk.yandex.ru/preview/.../image1.png
- site.ru/data/folder/.../image2.jpg and so on.
In the presence of a wagon and a small cart of such addresses. How, besides manual, can one process the existing records of image paths in articles in the database in such a way as to cut off all paths to the image name from the link address, and then add my own path to the new image storage path to the image name?
Let me explain:
- you need from this:
- downloader.disk.yandex.ru/preview/.../image1.png
- site.ru/data/folder/.../image2.jpg
-
do this:
- mysite/img/ folder/image1.png
- mysite/img/folder/image2.jpg
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question