External image storage

  • Posts: 180
  • Thank you received: 13
12 years 2 weeks ago #47363

We already have the images stored in a server. Is there a way to just pass the url of where the images reside, without importing the images into Hikashop?

Please Log in or Create an account to join the conversation.

  • Posts: 81597
  • Thank you received: 13081
  • MODERATOR
12 years 2 weeks ago #47549

Move your images via FTP under the folder media/com_hikashop/upload and you can then do that by using the import from textarea feature (menu Products->Import) with that text:

product_code,images
myproduct1,myimage1.jpg
myproduct2,myimage2.jpg
...etc...

Please Log in or Create an account to join the conversation.

  • Posts: 180
  • Thank you received: 13
12 years 2 weeks ago #47555

Thanks for the reply. But that is still effectively importing them into the system.

I just want to pass the URL where the image already resides and have it display while still on the image server. e.g. I want to pass www.imagestore.com/myimage.jpg to the product definition.

Please Log in or Create an account to join the conversation.

  • Posts: 81597
  • Thank you received: 13081
  • MODERATOR
12 years 1 week ago #47738

You can use the URL of the images in the CSV files if you import the products via CSV, however, the image won't be used directly. It will be copied to the upload folder of HikaShop so that HikaShop can resize it, etc.

Please Log in or Create an account to join the conversation.

  • Posts: 180
  • Thank you received: 13
12 years 1 week ago #47759

Thanks again for the reply Nicolas. It is appreciated.

Surely this is just what path the code which does the conversion uses. Is it possible for you, or someone else, to point me to the file which does the conversion of images into the thumbs displayed?

Last edit: 12 years 1 week ago by esotechie.

Please Log in or Create an account to join the conversation.

  • Posts: 81597
  • Thank you received: 13081
  • MODERATOR
12 years 1 week ago #47889

It's the file administrator/components/com_hikashop/helpers/image.php

The following user(s) said Thank You: esotechie

Please Log in or Create an account to join the conversation.

  • Posts: 180
  • Thank you received: 13
12 years 1 week ago #47895

Thank you very much Nicolas. Your help is greatly appreciated.

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 2
11 years 9 months ago #57450

On a similar line to this topic I would like to have the media/uploads and media/uploads/safe folders stored on an amazon s3 bucket

I've seen the joomlart extension www.joomlart.com/joomla/extensions/ja-amazon-s3 which I think can acheive my aim, but I wondered if anyone had:
1. any sucess integrating that extension with hikashop; and /or
2. if anyone has any other way of allowing hikashop to use an external storage (other than as described above)

Kind regards


Ben

Please Log in or Create an account to join the conversation.

  • Posts: 81597
  • Thank you received: 13081
  • MODERATOR
11 years 9 months ago #57461

Since 1.5.7 you can use external storage for files in HikaShop.
Just enter the URL instead of upload the file when you add it to the product.
For images however, it's not possible as the thumbnails have to be generated by HikaShop so the images have to be stored locally.

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 2
11 years 9 months ago #57481

yes I've tried that but when I include http:// in the cvs import file it just ignores the whole address, when I don't include http:// then it just doesn't work as it looks for the file locally with a really long address.
I've tried using "" and '' to surround the file statement but neither work

When I manually add the file with http:// then it works like a charm

any thoughts?

p.s.
I've also tried changing the location of the file upload path in the configuation to the root of the external site; I didn't expect this to work and it didn't!

Last edit: 11 years 9 months ago by bendraper.

Please Log in or Create an account to join the conversation.

  • Posts: 81597
  • Thank you received: 13081
  • MODERATOR
11 years 9 months ago #57485

The import system will try to download the files if you put URLs in the CSV.
It won't add the URL in the database.

That's normal that it doesn't work, regardless of the quotes you're using around it.

You would have to edit the file administrator/components/com_hikashop/helpers/import.php and remove that part so that it doesn't do that:

$unset = array();
			foreach($product->files as $k => $file){
				if(substr($file,0,7)=='http://'){
					$parts = explode('/',$file);
					$name = array_pop($parts);
					if(!file_exists($this->uploadFolder.$name)){
						$data = @file_get_contents($file);
						if(empty($data) && !empty($this->default_file)){
							$name = $this->default_file;
						}else{
							JFile::write($this->uploadFolder.$name,$data);
						}
					}
					if(filesize($this->uploadFolder.$name)){
						$product->files[$k] = $name;
					}else{
						$unset[]=$k;
					}
				}
			}
			if(!empty($unset)){
				foreach($unset as $k){
					unset($product->files[$k]);
				}
			}

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 2
11 years 9 months ago #57488

Thank you that works perfectly now

Ideally i'd like the file name and the file path to be different, I've removed the uploading part so the section now reads

			$unset = array();
			foreach($product->files as $k => $file){
				if(substr($file,0,7)=='http://'){
					$parts = explode('/',$file);
					$name = array_pop($parts);
					if(filesize($this->uploadFolder.$name)){
						$product->files[$k] = $name;
					}else{
						$unset[]=$k;
					}
				}
			}
			if(!empty($unset)){
				foreach($unset as $k){
					unset($product->files[$k]);
				}
			}

I can see that $name becomes the file name, but I can't see where $file disappears to and I can't see how either fit with the (and I assume I'm looking at the right function later in the import.php) _insertFiles function

The only reason that I want to do this becuase if the full file path is given as the name then it looks bad on the order form and also allows the customer to see where the files are located - potentially allowing them to access the other files.

Thanks for your help so far

Please Log in or Create an account to join the conversation.

  • Posts: 81597
  • Thank you received: 13081
  • MODERATOR
11 years 9 months ago #57548

You need to remove the full code there.
Then, in the _insertFiles, you will have to extract the name of the file from the URL and add it in the insert SQL query.

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
11 years 8 months ago #60639

I tried to use URLs for images on CSV import, but this does not work. The problem is probably related to the URL and the "name" of the image:

myimageserver.com/GetProductImage.aspx?i...ntid=163616359233856

I can see the file is uploaded to the upload folder, and it has the filename "GetProductImage.aspx?id=3&clientid=163616359233856". Everything before the . is used as image name, but I guess .aspx?id=3&clientid=163616359233856 is an unknown file extension when trying to use the image.

Any solution to how this can be solved easily?

Please Log in or Create an account to join the conversation.

  • Posts: 81597
  • Thank you received: 13081
  • MODERATOR
11 years 8 months ago #60703

You should some code after the line:
$name = array_pop($parts);

in the import.php file in order to generate a correct file name.

For example:
$name = 'file_'.rand().'.jpg';

That will use a filename file_12354.jpg where 12354 is a random number.

Please Log in or Create an account to join the conversation.

Time to create page: 0.103 seconds
Powered by Kunena Forum