0

I have image url like https://lipsum.mobi/catalog/product/SE0229E/YG/AAA/4/1/SE0229E-YG-AAA-4.jpg' and need to add 240x240 in that url.

Current Url: https://lipsum.mobi/catalog/product/SE0229E/YG/AAA/4/1/SE0229E-YG-AAA-4.jpg

Expected Output: https://lipsum.mobi/catalog/product/240x240/SE0229E/YG/AAA/4/1/SE0229E-YG-AAA-4.jpg

Is there any easy way to do in javascript? Thanks!

Swift
  • 790
  • 1
  • 5
  • 19
  • Yes it is. Just learn how use regular expression – Mr Zach Jun 30 '20 at 05:22
  • 1
    hi @Anush Kumar, the image is rendered by its pathname, if you need to change the original path of the image, it won't render it throws 404 Not found. so it's better to create a folder 240x240 after the product folder and then keep remain thing the same. – CodeBug Jun 30 '20 at 05:25

1 Answers1

0

If your URLs are always starting with the same category / prefix like "https://lipsum.mobi/catalog/product" or just have the same amount of characters, there is a topic explaining how to do this

Karol Pawlak
  • 440
  • 4
  • 15