Post by IP_CAM » Wed Sep 16, 2015 10:08 am

I have put together a few sample files, a while ago:
http://www.opencart.com/index.php?route ... n_id=23506

Further: In order to have ALL images 'DONE', it takes a little work, to find, troughout the ALL_FILENAMES.TPL Source-Files, all image Links, and manually hardcode the width+height, where real VALUES are missing on Browser Page Source. In Addition, in some VqMod's may be some image Links as well, they have to be renamed too, if one wants to make it complete.

Ernie
bigmax.ch/shop/

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 saliverdim » Sun Mar 06, 2016 8:31 am

ı Looking oc mod or vqmod oc 2.0.3.1

1-Specify image dimensions opencart
2-Serve scaled images opencart

can you help me ?

Active Member

Posts

Joined
Wed Oct 07, 2015 12:15 am

Post by esponi » Tue Sep 06, 2016 10:50 pm

Have you found it?

New member

Posts

Joined
Fri Jul 20, 2012 2:05 am

Post by IP_CAM » Sat Oct 29, 2016 7:55 am

saliverdim wrote:ı Looking oc mod or vqmod oc 2.0.3.1
1-Specify image dimensions opencart
2-Serve scaled images opencart
can you help me ?
As I recall, such Mod exists already for some OC-2.
But I cannot longer create&test such Mod's, because I have no working V-2 Versions online.
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 guidone » Mon Oct 02, 2017 6:14 pm

Hi,

for OC 2 i'm using this vQmod, is any problem with this?

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<modification>
	<id>Images width and height tags</id>
	<version>1.0.0</version>
	<vqmver required="true">2.4.0</vqmver>
	<author>me</author>
	<file name="catalog/model/tool/image.php">
		<operation>
			<search position="replace"><![CDATA[$image_new;]]></search>
			<add><![CDATA[$image_new . '" width="' . $width . '" height="' . $height;]]></add>
		</operation>
	</file>
</modification>

User avatar
New member

Posts

Joined
Thu Mar 28, 2013 7:39 pm

Post by IP_CAM » Tue Oct 03, 2017 4:01 am

I explained it here, and added a VqMod as well as an OcMod to it:
viewtopic.php?f=190&t=185410&p=686890#p686890
Good Luck! ;)
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 tonkp » Mon Oct 09, 2017 12:57 pm

It works! Thank You



sbobet

Newbie

Posts

Joined
Fri Sep 08, 2017 3:41 pm

Post by guidone » Tue May 11, 2021 2:22 am

This code it works great but on main domain only, not multistore, any solution?
Thanks
byens wrote:
Tue Jan 07, 2014 5:38 pm
Qphoria wrote:According to Google Page Speed tips. One tip is for web pages to include the width/height tags in the rendered html.
http://code.google.com/speed/page-speed ... Dimensions

So I did some playing with regex on the output code and it seems to be working.
This code will automatically generate the image size tags and insert them into every img tag in your page to comply with the Google Page Speed image tips automatically.

Not sure of the overall performance hit but it works. YMMV:

1. EDIT: system/library/response.php
2. FIND:

Code: Select all

if ($this->level) {
3. BEFORE, ADD:

Code: Select all

//Q: Add width/height tags to all images for Google Page Speed tip:
	        //http://code.google.com/speed/page-speed/docs/rendering.html#SpecifyImageDimensions
	        preg_match_all('/<img[^>]+>/i', $this->output, $result);

	        $img = array();
	        foreach($result[0] as $img_tag) {
	            preg_match_all('/(width|height|src)=("[^"]*")/i',$img_tag, $img[$img_tag]);
	        }

	        foreach ($img as $k => $info) {
	            if (count($info) == 3 && $info[1][0] == 'src') {
					//if (curl_init(str_replace('"', '', $info[2][0]))) {
					$imgfile = str_replace('"', '', $info[2][0]);
					$imgfile = str_replace(HTTP_SERVER, DIR_IMAGE . '../', $imgfile);
					$imgfile = str_replace(HTTPS_SERVER, DIR_IMAGE . '../', $imgfile);
	                if (file_exists($imgfile)) {
	                    $image_info = getImageSize(str_replace('"', '', $imgfile));
	                    $k = trim($k, '/>');
	                    $k = trim($k, '>');
	                    $this->output = str_replace($k, ($k . ' ' . $image_info[3]), $this->output);
	                }
	            }
	        }
	        //
      
with q's mod, i have better result.

However it returns error:
PHP Notice: Undefined offset: 0 in /srv/users/serverpilot/apps/tokolingerie/public/system/library/response.php on line 66

line 66: if (count($info) == 3 && $info[1][0] == 'src') {

php5.5+nginx opencart1.5.4.1

Anyone have solution for this?

User avatar
New member

Posts

Joined
Thu Mar 28, 2013 7:39 pm

Post by DoctorDredd » Sun Sep 12, 2021 9:12 pm

Qphoria wrote:
Wed Sep 15, 2010 11:18 pm

Code: Select all

//Q: Add width/height tags to all images for Google Page Speed tip:
	        //http://code.google.com/speed/page-speed/docs/rendering.html#SpecifyImageDimensions
	        preg_match_all('/<img[^>]+>/i', $this->output, $result);

	        $img = array();
	        foreach($result[0] as $img_tag) {
	            preg_match_all('/(width|height|src)=("[^"]*")/i',$img_tag, $img[$img_tag]);
	        }

	        foreach ($img as $k => $info) {
	            if (count($info) == 3 && $info[1][0] == 'src') {
					//if (curl_init(str_replace('"', '', $info[2][0]))) {
					$imgfile = str_replace('"', '', $info[2][0]);
					$imgfile = str_replace(HTTP_SERVER, DIR_IMAGE . '../', $imgfile);
					$imgfile = str_replace(HTTPS_SERVER, DIR_IMAGE . '../', $imgfile);
	                if (file_exists($imgfile)) {
	                    $image_info = getImageSize(str_replace('"', '', $imgfile));
	                    $k = trim($k, '/>');
	                    $k = trim($k, '>');
	                    [b]$this->output = str_replace($k, ($k . ' ' . $image_info[3]), $this->output);[/b]
	                }
	            }
	        }
	        //
      
This is wonderful code. To much speed up site. But come some small foult:

Notice: Trying to access array offset on value of type bool in /vqmod/vqcache/vq2-system_library_response.php on line 168

$this->output = str_replace($k, ($k . ' ' . $image_info[3]), $this->output);
And also strached images. Opencart 1.5.6.5 Please help to repair. Thanks in advance.!

Attachments

tmp-cam-7368236236797851983.jpg

tmp-cam-7368236236797851983.jpg (56.71 KiB) Viewed 3772 times

tmp-cam-5647590236441118074.jpg

tmp-cam-5647590236441118074.jpg (91.24 KiB) Viewed 3772 times


Newbie

Posts

Joined
Wed Jul 29, 2020 7:38 pm
Who is online

Users browsing this forum: No registered users and 14 guests