Post by lz1nud » Wed Apr 08, 2015 11:55 pm

Any plans for opencart to handle new WebP image format? Or parhaps extention module to be able to convert and read those images. It will be great for speeding up sites.

Sky-Mag Bulgaria


Active Member

Posts

Joined
Thu Feb 13, 2014 5:35 am
Location - Bulgaria

Post by IP_CAM » Thu Apr 09, 2015 6:23 pm

What's the Use of it, if no Browsers will display it? It may be a very usable future Option, but at present, it's about as useful as a dead cat.
Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

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

Post by lz1nud » Thu Apr 09, 2015 8:23 pm

Old browsers can read it with java script, new ones will have the feature to read it. After all this is google development with free open source code. The image can be transparent, so it can replace bigger PNG files too.

Sky-Mag Bulgaria


Active Member

Posts

Joined
Thu Feb 13, 2014 5:35 am
Location - Bulgaria

Post by fido-x » Tue Apr 14, 2015 3:30 pm

It doesn't matter whether the browser supports it or not.

Even if you added the extension and mime types to the supported list under the "Server" tab in your store settings in the admin and modified the image library functions, if it is not supported by PHP, then you are just wasting your time.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by Rainforest » Sat Jan 05, 2019 5:02 am

resurrecting this as now in 2019 70+% of browsers can.
Thank you...next.
So any plans for OC to adopt this?

Self Taught Opencart User & Developer Since 2010.


User avatar
Active Member

Posts

Joined
Fri Jan 28, 2011 3:50 am

Post by eaglenik » Sun Feb 24, 2019 11:30 pm

Any info regarding this matter ? Thank you !

Newbie

Posts

Joined
Mon Jan 28, 2019 3:10 am

Post by letxobnav » Fri Mar 01, 2019 9:56 pm

not so difficult to add this yourself in the image class.
but keep in mind that you will have to cache both jpg and webp versions of the images as not all browsers accept webp.
and you have to perform the accept check to determine if you return webp or jpg.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by letxobnav » Fri Mar 01, 2019 10:03 pm

and your version of gd has to support it so for every image output you have to perform the check.

Code: Select all

	public function webpSupport() {
		$support = false;
		$gd = gd_info();
		// if gd supports webp
		if ($gd['WebP Support']) {
			// if browser accepts webp images
			if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'webp')) {
				$support = true;
			}
		}
		return $support;
	}	

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by straightlight » Fri Mar 01, 2019 10:11 pm

If the above code needs to be added in an Opencart PHP file, replace this line:

Code: Select all

if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'webp')) {
with:

Code: Select all

if (isset($this->request->server['HTTP_ACCEPT']) && strpos($this->request->server['HTTP_ACCEPT'], 'webp')) {

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by letxobnav » Sat Mar 02, 2019 3:17 pm

true, and if you are sure your php gd version support webp you can take out the gd_info() part of the check.

then you would send out the right images by:

Code: Select all

if ($this->request->server['HTTPS']) {
	return $this->config->get('config_ssl') . 'image/' . ($this->webp_support() ? $your_webp_image : $your_jpg_image);
} else {
	return $this->config->get('config_url') . 'image/' . ($this->webp_support() ? $your_webp_image : $your_jpg_image);
}

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by straightlight » Sat Mar 02, 2019 8:44 pm

letxobnav wrote:
Sat Mar 02, 2019 3:17 pm
true, and if you are sure your php gd version support webp you can take out the gd_info() part of the check.

then you would send out the right images by:

Code: Select all

if ($this->request->server['HTTPS']) {
	return $this->config->get('config_ssl') . 'image/' . ($this->webp_support() ? $your_webp_image : $your_jpg_image);
} else {
	return $this->config->get('config_url') . 'image/' . ($this->webp_support() ? $your_webp_image : $your_jpg_image);
}
In accordance to: http://php.net/manual/en/image.constants.php , as for PHP v7.1.0 , there's a similar way to adapt this without validation needed in both admin/model/tool/image.php and catalog/model/tool/image.php files.

Find:

Code: Select all

if (!in_array($image_type, array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF))) { 
replace with:

Code: Select all

if (!in_array($image_type, array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_WEBP))) {
since IMAGETYPE_WEBP, in this case, is already verified with the image size. When that fails, the old image file will be loaded on anyhow.

Note: Not a replacement solution, simply an addition to it.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by arcovirtual » Wed Jun 05, 2019 11:05 am

I have a mod from a developer, which generates a constant error every certain hour of the day, and it has to do with the same thing that you are talking about in this thread,
the code with problems is this,

Code: Select all

	public function webpSupport() {
				$mod = 'rm_lwi';
				$support = false;
				if ($this->config->get($mod . '_status') && $this->config->get($mod . '_webp_status')) {
					$gd = gd_info();
					if ($gd['WebP Support'] && strpos( $_SERVER['HTTP_ACCEPT'], 'webp' ) ) { //this line error HTTP_ACCEPT unable or empty
						$support = true;
					}
				}
				return $support;
			}
I am trying to do this with what I have read from you:

Code: Select all

	if ($gd['WebP Support'] && (strpos( $_SERVER['HTTP_ACCEPT'], 'image/webp' ) !== false )) {
I have to wait until tomorrow to check if this solves that error

New member

Posts

Joined
Thu Jul 07, 2016 9:49 am

Post by arcovirtual » Wed Jun 05, 2019 11:21 am

ok the error follow:
PHP Notice: Undefined index: HTTP_ACCEPT in /home/........./public_html/system/storage/modification/catalog/model/tool/image.php on line 8

Code: Select all

if ($gd['WebP Support'] && (strpos( $_SERVER['HTTP_ACCEPT'], 'image/webp' ) !== false )) {
I do not know how to solve it

New member

Posts

Joined
Thu Jul 07, 2016 9:49 am

Post by arcovirtual » Wed Jun 05, 2019 11:27 am

I will try with this:

Code: Select all

public function webpSupport() {
				$mod = 'rm_lwi';
				$support = false;
				if ($this->config->get($mod . '_status') && $this->config->get($mod . '_webp_status')) {
					$gd = gd_info();
					if ($gd['WebP Support'])
					{
			// if browser accepts webp images
			if (isset($this->request->server['HTTP_ACCEPT']) && strpos($this->request->server['HTTP_ACCEPT'], 'webp')) {
			
						$support = true;
					}
				}
				return $support;
			}
			}
			

New member

Posts

Joined
Thu Jul 07, 2016 9:49 am

Post by IP_CAM » Wed Jun 05, 2019 11:41 am

did you really define this http-accept command/whatever /variable ?
if it's not defined, it can not be understud and handled accordingly, since it's
not an OC default global variable, as I am aware of.
Ernie
https://stackoverflow.com/questions/513 ... ttp-accept

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

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

Post by straightlight » Wed Jun 05, 2019 7:19 pm

See this topic for WebP support: viewtopic.php?f=121&t=210243&p=748237#p747798

As for the HTTP_ACCEPT, see this post for more info: https://stackoverflow.com/questions/502 ... ttp-accept .

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by dparakhiya » Wed Jun 05, 2019 8:25 pm


For quick, professional OpenCart support
Online
contact me on skype : dparakhiya_1
email : dipneshp@gmail.com


User avatar
New member

Posts

Joined
Fri Jul 28, 2017 1:13 pm
Location - India

Post by straightlight » Wed Jul 17, 2019 10:09 am

dparakhiya wrote:
Wed Jun 05, 2019 8:25 pm
Maybe this Module useful: https://www.opencart.com/index.php?rout ... n_id=36923
I am not sure how useful it could become since it has a 404 error message on the page.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

User avatar
Active Member

Posts

Joined
Fri Mar 16, 2012 10:18 am
Location - Canada, QC

Post by by mona » Sun Feb 13, 2022 8:36 am

For a more complete solution, developed to include all images not just product thumbs.

https://www.opencart.com/index.php?rout ... n_id=43173

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: No registered users and 19 guests