Post by neowing » Sun Dec 05, 2010 10:50 am

I could not find external image function for the product in version 1.4.9.1 of opencart.

But sometimes i feel that using external image link will save more time to do product data entry, and easy to locate the image, especially when the connecting speed to server is going down.

i will be very happy if anyone can tell me more about this.

Newbie

Posts

Joined
Sun Nov 21, 2010 3:49 pm

Post by justinv » Sun Dec 05, 2010 11:30 am

I agree - I think images show up correctly in admin if they are entered as absolute urls, but they do not work on site as the image resizing functions open only files, not urls. I think there should be an easy way to allow images from other servers without messing with code, it would have helped me several times already. Obviously you'd have to either make sure images are the correct size on the server, or resize them in css (yuk).

Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN
Image


Active Member

Posts

Joined
Tue Oct 12, 2010 1:24 pm

Post by justinv » Sat Dec 11, 2010 1:09 pm

Here is a simple tweak to the OpenCart core to allow external image links for product images. It will mean that your images are no longer resized, but at least you will have images!

In the file catalog/model/tool/image.php, replace line 4 where it says this:

Code: Select all

return;
With this:

Code: Select all

return $filename;

I hope that helps someone else as much as it just helped me.

Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN
Image


Active Member

Posts

Joined
Tue Oct 12, 2010 1:24 pm

Post by honk » Thu Dec 16, 2010 1:23 am

try this extension:
http://www.opencart.com/index.php?route ... order=DESC
This plugin can replace the default Opencart "Image Manager".
You can select images from your Google Picasa Web Albums directly(I think Flickr is comming soon).
No need to upload image to your site, it makes your site more lightweight.
Because the images are hosted at google's server, it makes your site faster.

Live Image Selector, a good extention for opencart


Newbie

Posts

Joined
Fri Apr 24, 2009 11:56 pm

Post by NTCommerce » Fri Jun 17, 2011 10:46 pm

justinv wrote:Here is a simple tweak to the OpenCart core to allow external image links for product images. It will mean that your images are no longer resized, but at least you will have images!

In the file catalog/model/tool/image.php, replace line 4 where it says this:

Code: Select all

return;
With this:

Code: Select all

return $filename;

I hope that helps someone else as much as it just helped me.
So simple yet afer three days of trying to suss this in 1.5.0.3 has just probably secured me a very large web development project. If we ever meet I'll by you a pint.
Thankyou

New member

Posts

Joined
Tue Jun 14, 2011 7:51 pm

Post by Lobart78 » Sat Jul 07, 2012 12:47 am

Brilliant now images are loaded from external url thanks justin. However, is it possible to state the size of the image in thy php?

Newbie

Posts

Joined
Tue Jan 03, 2012 11:33 pm

Post by justinv » Wed Jul 18, 2012 12:00 pm

You'd need to state the size in the CSS - in tpl files, or directly in your CSS files.

Documentation: OpenCart User Guide
Mods: Total Import PRO | CSV Import PRO | Ecom Tracking | Any Feed | Autosuggest | OpenCart CDN
Image


Active Member

Posts

Joined
Tue Oct 12, 2010 1:24 pm

Post by skullnbones » Mon Mar 25, 2013 11:11 am

How do you state the size in the CSS - in tpl files?

I have changed the size in my CSS but the image size has stayed the same. How do you change it in the tpl files?

Newbie

Posts

Joined
Mon Mar 25, 2013 11:08 am

Post by MicroCNC » Tue Dec 10, 2013 1:41 pm

Hopefully this might help somebody out.

replace catalog/model/tool/image.php line 16

Code: Select all

return;
with

Code: Select all

if (substr($filename, 0, 7) == 'http://') {
return $filename.'" height="'.$height.'" width="'.$width;
} else {
return;
}
It will check that the $filname starts with http:// and will use the variables passed from resize() to resize the image from the url.

I have this working on my shop http://microcnc.net/shop/

Newbie

Posts

Joined
Tue Dec 10, 2013 1:30 pm

Post by tgondal » Tue Sep 02, 2014 2:12 am

HI everyone,

Thank you for the code, it does loads the images for external URL. However, there is a problem when you click on additional images below main product image, it opens the additional image from external site and takes the user out from my store. Any advice please

Thank you

Newbie

Posts

Joined
Mon Jul 21, 2014 1:48 am

Post by murri » Wed Mar 25, 2015 11:32 pm

Thank you for the code! It saved me some time and trouble. :ok:

Newbie

Posts

Joined
Sun Feb 08, 2015 12:47 am

Post by IP_CAM » Thu Mar 26, 2015 3:38 am

Now this is, what surpasses my (php code) wisdom, and I guess, some others could 'use/profit from' this information as well. (catalog/model/tool/image.php)
So, using the (believed) default oc v.1.5.6.4 image.php template, I have this:

Code: Select all

	public function resize($filename, $width, $height, $type = "") {
		if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
		return;
		} 
Should I now ADD the external link Mod like THIS:

Code: Select all

	public function resize($filename, $width, $height, $type = "") {
		if (substr($filename, 0, 7) == 'http://') {
		return $filename.'" height="'.$height.'" width="'.$width;
		} elseif (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
		return;
		} 
		}
to make it work in BOTH WAYS? ???
I like to test a lot, but not really everything, by myselfs. :-\
Thanks a lot! (will try to give it back, some place...!)
Ernie

I'm rarely active at the OC Forum lately. To reach me, contact: jti@jacob.ch
A Demoversion of my free OpenCart LIGHT v.1.5.6.5 Software Edition
can be seen in real Action here: http://www.jti.li/shop/
---
1'300+ FREE OC Extension-Repositories - from OC v.1.5.x up,
on the world's largest OC-related Github Site: https://github.com/IP-CAM
---
Image


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by ajrjain7 » Thu Apr 02, 2015 2:47 am

I am facing similar type issue , trying to add images and youtube videos on Information page, but once after saving it is modifying the url which causing Not Found Error for image and videos

opencart 2.0.1.1 , check below page where i tried to add correct url of video yet, facing issue
http://gymtrekkerstore.com/gymcart/inde ... ation_id=8
please help

Newbie

Posts

Joined
Wed Mar 25, 2015 12:17 am

Post by IP_CAM » Sat Apr 04, 2015 8:24 pm

Because your'e trying to call the Movie by USE of an internal SERVER Path Link, as shown, when checking your HREF-Line:
>> /gymcart/\"https://www.youtube.com/embed ... <<

Ernie

I'm rarely active at the OC Forum lately. To reach me, contact: jti@jacob.ch
A Demoversion of my free OpenCart LIGHT v.1.5.6.5 Software Edition
can be seen in real Action here: http://www.jti.li/shop/
---
1'300+ FREE OC Extension-Repositories - from OC v.1.5.x up,
on the world's largest OC-related Github Site: https://github.com/IP-CAM
---
Image


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by chardon » Thu Jan 07, 2016 6:11 pm

I tried this for OC 2.1.0.1 but I got an error, please what is the updated version for 2.1.0.1 for image.php?

Warning: getimagesize(/home/b1102/public_html/image/https://storefront.com/Commerce/imageCo ... TDR250.jpg): failed to open stream: No such file or directory in /home/b1102/public_html/catalog/model/tool/image.php on line 26Error: Could not load image /home/b1102/public_html/image/https://storefront.com/Commerce/imageCo ... TDR250.jpg!

Newbie

Posts

Joined
Thu Jan 07, 2016 6:05 pm

Post by IP_CAM » Fri Jan 08, 2016 9:12 am

1. this cannot work, you have a linked placed after the internal Server Path.
/home/b1102/public_html/image/https://storefront.com/Commerce/image
2. This is NO Opencart v.2.x Code, you display above.

Ernie
openshop.li/cart/

I'm rarely active at the OC Forum lately. To reach me, contact: jti@jacob.ch
A Demoversion of my free OpenCart LIGHT v.1.5.6.5 Software Edition
can be seen in real Action here: http://www.jti.li/shop/
---
1'300+ FREE OC Extension-Repositories - from OC v.1.5.x up,
on the world's largest OC-related Github Site: https://github.com/IP-CAM
---
Image


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by chardon » Fri Jan 08, 2016 9:25 am

It's the error I got in my open cart 2 admin while logged into opencart. I tried import/export open cart extension with image http:// link after I added this code below to my image.php

public function resize($filename, $width, $height, $type = "") {
if (substr($filename, 0, 7) == 'http://') {
return $filename.'" height="'.$height.'" width="'.$width;
} elseif (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
return;
}
}

Newbie

Posts

Joined
Thu Jan 07, 2016 6:05 pm

Post by chardon » Fri Jan 08, 2016 11:14 am

It;s an error with the file path....it's including the server path along with the http://

Newbie

Posts

Joined
Thu Jan 07, 2016 6:05 pm

Post by IP_CAM » Fri Jan 08, 2016 12:47 pm

it's not an error, you are addressing the PATH, by USE of DIR_IMAGE, instead of HTTP linking by using HTTP_IMAGE, because then, it would work, I assume, anyway :D
Ernie

I'm rarely active at the OC Forum lately. To reach me, contact: jti@jacob.ch
A Demoversion of my free OpenCart LIGHT v.1.5.6.5 Software Edition
can be seen in real Action here: http://www.jti.li/shop/
---
1'300+ FREE OC Extension-Repositories - from OC v.1.5.x up,
on the world's largest OC-related Github Site: https://github.com/IP-CAM
---
Image


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by hillfingerr » Wed Apr 19, 2017 6:40 am

I am using Opencart 1.5.6.4 and for the below code works to use both external and internal images, but unfortunately it has two issues:

1. for the external images, I can't use https urls and for my ssl site this causes mixed content errors and the connection is not secure anymore and seo suffers.

2. if any additional images are clicked, they follow the link to the external source instead of the normal behavior to show the large image on my site.

Is there anyone knowledgeable in php and willing to help to revise the code so these will be fixed?

MicroCNC wrote:
Tue Dec 10, 2013 1:41 pm

replace catalog/model/tool/image.php line 16

Code: Select all

return;
with

Code: Select all

if (substr($filename, 0, 7) == 'http://') {
return $filename.'" height="'.$height.'" width="'.$width;
} else {
return;
}

New member

Posts

Joined
Mon May 26, 2014 8:22 pm
Who is online

Users browsing this forum: No registered users and 48 guests