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

For Sale: Turnkey URLs with Opencart installed
My present Opencart Testsite: http://www.velomech.ch/shop/
Attacker IP Blocks are denied from further access to my Sites!
Just contact me for more Information at: jti@jacob.ch
690 FREE OC Extension-Repositories - from OC v.1.5.x up
on the largest Opencart-Mod 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 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?

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


Active Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm

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


Active Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm

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')) {

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


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


Active Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm

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.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

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

Users browsing this forum: No registered users and 4 guests