Jump to content

[SOLVED]Import image product with relative URL


Recommended Posts

Hello, i want to import some images for the products (2 per product).

 

I can do it perfectly with the absolute url like this:

http://www.canon.es/Images/Canon_Logo_350_tcm86-959888.jpg

But when i want to use some images from my own proyect i want use a relative path like this:

img/peliculas/dvd/front/P00050.jpg

and it doesn't work.

 

 

Any idea to solve this??

Edited by Reco-X (see edit history)
Link to comment
Share on other sites

locally? on localhost? just use the link as you'd do with a localhost page ;)

 

See, if i want to use the image in local the url will be

http://localhost/prestashop/img/peliculas/dvd/front/P00050.jpg

but when i upload the site to production the url will be

http://www.BLABLABLA.com/img/peliculas/dvd/front/P00050.jpg

did you understand my problem?

 

 

For the comments of you 2 guys, I understood it's impossible, but i must to resolve this doubt :ph34r:.

Edited by Reco-X (see edit history)
Link to comment
Share on other sites

no,  this url will NEVER be the image url of a product: http://localhost/prestashop/img/peliculas/dvd/front/P00050.jpg

 

Because when you import, prestashop moves the images to its own directory. Then, links  are generated on the fly. Therefore, whn you move the site to live, if might don't even need to regenerate thumbs again ;)

  • Like 2
Link to comment
Share on other sites

  • 1 year later...

no,  this url will NEVER be the image url of a product: http://localhost/prestashop/img/peliculas/dvd/front/P00050.jpg

 

Because when you import, prestashop moves the images to its own directory. Then, links  are generated on the fly. Therefore, whn you move the site to live, if might don't even need to regenerate thumbs again ;)

 

But if you copy complete PS from Localhost to destination on real server, and your images are already imported, url of images are copied i database with localhost url. Not true?

 

I´ve put relative url to img in source:

<img src="../img/cms/0902.jpg" />

 

and to htaccess. I´ve added:

RewriteRule ^(.*)/img/cms/(.*).(jpe?g|png|gif)$ %{ENV:REWRITEBASE}img/cms/$2.$3 [NC,L]

before this:

# Images

But still be carefull to prestashop can change htaccess.

This rule works on thet place, not before # ~~start~~   and not after # ~~end~~

 

Maybe it is not general solution. It worked for me, and not in multilanguage version (maybe..)

Edited by janoo (see edit history)
Link to comment
Share on other sites

well no, it's never going to work as product image for the simple reason that is not the path to any existing folder for product images, there are no subfolders named like that, unless you add a very specific rewrite rule for it (but it would be cray to, for each product) :)
Cms images are different, that's why your solution works :) There is no reference to the product image link in the db :)

Link to comment
Share on other sites

  • 7 months later...

Hoping Nemo1 can help as I have been watching your videos on youtube.

 

I have uploaded images (10) to Catalog/Products/ for a specific new product.  I want to use the IMPORT function CSV file to create COMBINATIONS since I am getting an average of 48-72 different combos on my products.  

 

I want a specific image to show with the combination - I have been manually updating it after I use the Combination Generator but its taking me hours. 

 

The CSV seems to need the image URL - how do I find that for the images I uploaded to Prestashops Catalog/Products???

 

Thanks

Brian

Link to comment
Share on other sites

Hi Brian,

It would be easier if you hard those images hosted elsewhere. Since you don't, and they are part of the product, the quickest way I know is just checking the product in the front office and get them that way, the bigger version of course

Link to comment
Share on other sites

  • 1 year later...

hi there...im having trouble uploading images. dont really know how to create an "http:/......" link where the photos must be located so i can copy it into de csv document and then import it from prestashop. can you help me? thanks.!!!

You can use too every url linking an image, for example:

 

https://www.google.co.id/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png

 

thats all.

 

 

Edited by Reco-X (see edit history)
Link to comment
Share on other sites

Hi all,

 

I was reading this subject and doing an import on the side. I always prefer to use relative copy for import purpose. it saves some time on import. I must say that I never used it on PrestaShop, thinking it was impossible.

 

Then I red Vekia saying (back in 2014) that he was unable to do relative path import. THAT was the moment a little voice in my head said : "Oh *?%! IT. IS. ON." And I set my self on reverse engineering mode ot see how we could do relative path with PrestaShop...I didn't consult documentation, because...sadly PrestaShop is lacking there!

 

What I found out : You can't use relative PATH* (I INSIST on word PATH). You can't use "./" or "../", your url will be exploded on "/", then reconstructed with a starting "/". Which means, if you use "../my_great_image.jpg", it will be rewrote as "/../my_great_image.jpg". You need to use absolute PATH (I still INSIST on word PATH).

 

So, let's say your filesystem map you app in "/home/user/domain/prestashop/", you need to use : "home/user/domain/prestashop/image-import/my_great_image.jpg"

 

Best regards to all,

Jedi out

 

Martin.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...