Post by Canou » Thu Jan 30, 2014 2:51 am

Hi. Thanks, but with this module, i've alway :
Image

Adoucisseur d'eau


Newbie

Posts

Joined
Thu Mar 07, 2013 2:15 am
Location - France

Post by golfmad123 » Wed Feb 19, 2014 3:38 am

Hi, this post has been really helpful but i have a slight problem. I hope you guys can please help me.

I posted Qphorias code into response.php

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);
                   }
               }
           }
           //


I then got an error message saying
Notice: Undefined offset: 0 in /home/sites/philipsgolf.co.uk/public_html/system/library/response.php on line 66Notice: Undefined offset: 0 in /home/sites/philipsgolf.co.uk/public_html/system/library/response.php on line 66Notice: Undefined offset: 0 in /home/sites/philipsgolf.co.uk/public_html/system/library/response.php on line 66Notice: Undefined offset: 0 in /home/sites/philipsgolf.co.uk/public_html/system/library/response.php on line 66

So I applied the change as suggested by Qphoria
Change

Code: Select all

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

Code: Select all

if (count($info) == 3 && isset($info[1][0]) && $info[1][0] == 'src') {
This worked but then brought the symbols *');" /> after the X for remove from cart and stopped it from working.
The modification also distorted my homepage logo on a mobile device and distorted the carousel images on a mobile deivice, but they displayed correct in a desktop browser.

I then tried a change as suggested by tkal to remove the *');" /> symbols
From Qphoria's first post change:

Code: Select all

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


to

Code: Select all

 foreach($result[0] as $img_tag) {
            if (!strpos($img_tag,'close.png'))
               preg_match_all('/(width|height|src)=("[^"]*")/i',$img_tag, $img[$img_tag]);
           }
This did not remove the *');" /> symbols.

So my code is looking like

Code: Select all

<?php
class Response {
	private $headers = array(); 
	private $level = 0;
	private $output;
	
	public function addHeader($header) {
		$this->headers[] = $header;
	}

	public function redirect($url) {
		header('Location: ' . $url);
		exit;
	}
	
	public function setCompression($level) {
		$this->level = $level;
	}
		
	public function setOutput($output) {
		$this->output = $output;
	}

	private function compress($data, $level = 0) {
		if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false)) {
			$encoding = 'gzip';
		} 

		if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip') !== false)) {
			$encoding = 'x-gzip';
		}

		if (!isset($encoding)) {
			return $data;
		}

		if (!extension_loaded('zlib') || ini_get('zlib.output_compression')) {
			return $data;
		}

		if (headers_sent()) {
			return $data;
		}

		if (connection_status()) { 
			return $data;
		}
		
		$this->addHeader('Content-Encoding: ' . $encoding);

		return gzencode($data, (int)$level);
	}

	public function output() {
		if ($this->output) {
			//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 && isset($info[1][0]) && $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);
                   }
               }
           }
           //
if ($this->level) {
				$ouput = $this->compress($this->output, $this->level);
			} else {
				$ouput = $this->output;
			}	
				
			if (!headers_sent()) {
				foreach ($this->headers as $header) {
					header($header, true);
				}
			}
			
			echo $ouput;
		}
	}
}
?>
Any ideas how to remove the *');" /> error from the checkout??

I would really appreciate some help, this post has been really informative, i am so close just got this tiny error to be fixed. As you can probably tell I am new to code. I hope i have provided all the necessary info. Also I am using version 1.5.5.1.

Thank You
Last edited by golfmad123 on Thu Feb 20, 2014 6:21 am, edited 2 times in total.

Newbie

Posts

Joined
Fri Jan 03, 2014 3:32 am

Post by yorkfirearms » Wed May 07, 2014 5:45 am

golfmad123 wrote: Any ideas how to remove the *');" /> error from the checkout??

I would really appreciate some help, this post has been really informative, i am so close just got this tiny error to be fixed. As you can probably tell I am new to code. I hope i have provided all the necessary info. Also I am using version 1.5.5.1.

Thank You
I have the same issue. Any help?

Newbie

Posts

Joined
Sun Dec 29, 2013 9:55 pm

Post by mutemancer » Sat Jul 12, 2014 4:12 pm

Hallo,

I want use your auto width, hegiht tag xml file but I have one problem.

If I use it on my kravat page : www.verdtoneshop.com/kravat

It works well.

But If I use it on my gomlek category: www.verdtoneshop.com/gomlek

There is error. like

Warning: file_get_contents(): Unable to access /home/verdtone/public_html/image/cache/data/Gomlekler/4812-500A-02-200x260.jpg" width="200" height="260 in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 13Warning: file_get_contents(/home/verdtone/public_html/image/cache/data/Gomlekler/4812-500A-02-200x260.jpg" width="200" height="260): failed to open stream: No such file or directory in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 13Warning: imagecreatefromstring(): Empty string or invalid image in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 13Warning: imagesx() expects parameter 1 to be resource, boolean given in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 38Warning: imagecopy() expects parameter 1 to be resource, boolean given in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 115Warning: imagesavealpha() expects parameter 1 to be resource, boolean given in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 39Warning: imagepng() expects parameter 1 to be resource, boolean given in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 70Warning: file_get_contents(): Unable to access /home/verdtone/public_html/image/cache/data/Gomlekler/9999-500A-04-200x260.jpg" width="200" height="260 in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 13Warning: file_get_contents(/home/verdtone/public_html/image/cache/data/Gomlekler/9999-500A-04-200x260.jpg" width="200" height="260): failed to open stream: No such file or directory in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 13Warning: imagecreatefromstring(): Empty string or invalid image in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 13Warning: imagesx() expects parameter 1 to be resource, boolean given in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 38Warning: imagecopy() expects parameter 1 to be resource, boolean given in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 115Warning: imagesavealpha() expects parameter 1 to be resource, boolean given in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 39Warning: imagepng() expects parameter 1 to be resource, boolean given in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 70Warning: file_get_contents(): Unable to access /home/verdtone/public_html/image/cache/data/Gomlekler/9999-500A-05-200x260.jpg" width="200" height="260 in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 13Warning: file_get_contents(/home/verdtone/public_html/image/cache/data/Gomlekler/9999-500A-05-200x260.jpg" width="200" height="260): failed to open stream: No such file or directory in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 13Warning: imagecreatefromstring(): Empty string or invalid image in /home/verdtone/public_html/catalog/model/tool/labelimage.php on line 13Warning: imagesx() expects parameter 1 to be resource, boolean given in...

How can I fix it ?

Thank you so much !

Newbie

Posts

Joined
Sat Jul 12, 2014 3:42 pm

Post by Jaap » Sat Oct 18, 2014 5:24 am

I Installed the mod.
But this kills my page load time.
Plus 0.8 sec.

User avatar
Active Member

Posts

Joined
Fri Apr 15, 2011 12:10 am
Location - the Netherlands

Post by astott2014 » Sun Oct 19, 2014 11:12 am

I have done the instructions given in post 1, and It has totally messed me images sizes??

Active Member

Posts

Joined
Thu Sep 18, 2014 4:39 pm

Post by astott2014 » Tue Oct 21, 2014 9:30 am

Anyone? My images are all stretches higher when using this code, when I remove the code it works fine.

Active Member

Posts

Joined
Thu Sep 18, 2014 4:39 pm

Post by ForgetfulGuru » Mon Jan 26, 2015 6:36 pm

@ Qphoria, You are a STAR. ;D

Life is for the taking. It's everything else you need to pay for.
Anne Makes Lovely Candles


User avatar
New member

Posts

Joined
Sun Jul 22, 2012 11:12 pm
Location - Left hand corner as you enter the room, better feng shui.

Post by sud0074 » Wed Jan 28, 2015 2:42 am

Hello i am using Opencart v2.0, I want to show my products in Home page as Best seller product, for that i using Best Seller Extension [while i am adding in Best seller modules fields its show error (image width & height dimensions required)

what i did. 1-In bestseller modules when i clicked at plus button to add new modules, 2- Satus is Enable 2- I put it value 5 in Limit box and
3- in Image (W x H) and Resize Type Box i put value W-200 and H-200 (for dimensions) 4- then when i clicked on Save button 5- after that error massage will occur (image width & height dimensions required)]

I try lots of thing but didn't work, i change browser also clear catch but all fail, I also uploaded Screen Shot. please help me out what i am doing wrong.? tell me

Newbie

Posts

Joined
Sun Jan 25, 2015 9:41 pm

Post by ForgetfulGuru » Thu Jan 29, 2015 2:52 pm

With 200px being the defaults for width and height, first thing I'd try is deleting those values and putting something fresh in the boxes.
I would also uninstall the module and reinstall it from the main module's screen.

Life is for the taking. It's everything else you need to pay for.
Anne Makes Lovely Candles


User avatar
New member

Posts

Joined
Sun Jul 22, 2012 11:12 pm
Location - Left hand corner as you enter the room, better feng shui.

Post by sud0074 » Tue Feb 03, 2015 5:01 pm

@ForgetfulGuru
thanks for giving me feed back but sorry dear .. its also not working
What I did ..
I went in to Module> uninstall Bestseller Module >refresh browser>Install>Clicked Edit>Open Bestseller module>Select enable>add new one >Limit-4,Widht-100,Hight-100( I put fresh Value in all field) >Clicked Save>Error-"Image width & height dimensions required!"

Please tell me where I am wrong and how am I fixed this .

Newbie

Posts

Joined
Sun Jan 25, 2015 9:41 pm

Post by ForgetfulGuru » Tue Feb 03, 2015 6:54 pm

It may be seen as hi-jacking this thread, as it's not really what is being discussed here.

Follow this link to http://forum.opencart.com/viewforum.php?f=190

Ask your question there as it would be a more appropriate place for it.

Life is for the taking. It's everything else you need to pay for.
Anne Makes Lovely Candles


User avatar
New member

Posts

Joined
Sun Jul 22, 2012 11:12 pm
Location - Left hand corner as you enter the room, better feng shui.

Post by sud0074 » Tue Feb 03, 2015 10:02 pm

@ForgetfulGuru
thnks for this help .. would u like in touch with me .

Newbie

Posts

Joined
Sun Jan 25, 2015 9:41 pm

Post by BOBKIM7080 » Sun Feb 15, 2015 3:11 am

For v1.5.6
not works for "qphoria" method.
works "rph" method but my site drop down option menu not works at products page.
Any improvement for this treat?

User avatar
New member

Posts

Joined
Fri Aug 26, 2011 12:53 am


Post by dpinney » Mon Mar 30, 2015 9:42 pm

Any of these suggestions work with opencart 1.5.6.4 Thanks!

Newbie

Posts

Joined
Thu Jun 05, 2014 7:33 pm

Post by IP_CAM » Wed Jul 15, 2015 9:30 am

This one works for OC Version, up to v.1.5.6.5_rc:
it's called: image_width_height_tags_156.xml

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<modification>
<id>Image Width and Height Attributes</id>
<version>1.0.0</version>
<vqmver>2.3.2</vqmver>
<author>OpenCartHelp.com</author>
	<!--
	This isn't an ideal method for adding image width and height attributes
	as it relies on the template to provide the proper closing double-quote (") 
	but it does have the advantage of requiring a minimum of changes versus 
	a proper store wide MVC rewrite.  It will have no effect on non-resized images.  
	There may also be errors where the resize() method is used in non-tempate 
	areas such as a	product feed.
	-->
	<file name="catalog/model/tool/image.php">
		<operation error="log">
			<!--
				1.4.9.x - 1.5.4.1:
					return HTTPS_IMAGE . $new_image;
					return HTTP_IMAGE . $new_image;
				1.5.5.x - 1.5.6.5_rc:
					return $this->config->get('config_ssl') . 'image/' . $new_image;
					return $this->config->get('config_url') . 'image/' . $new_image;
			-->
			<search position="replace" regex="true"><![CDATA[~return (.*) \. \$new_image;~]]></search>
			<add><![CDATA[return $1 . $new_image . '" width="' . $width . '" height="' . $height;]]></add>
		</operation>
	</file>
</modification>
Good Luck ;)
Ernie
hitline.info/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 Axel Wers » Thu Jul 30, 2015 7:30 am

IP_CAM wrote:This one works for OC Version, up to v.1.5.6.5_rc:
it's called: image_width_height_tags_156.xml
Thanks, it seems this really works.

OC 2.3.0.2


New member

Posts

Joined
Fri Aug 22, 2014 3:59 pm

Post by IP_CAM » Thu Jul 30, 2015 8:30 am

Your'e welcome!
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 jaydean » Mon Aug 24, 2015 8:36 am

I tried this mod and it only works when I manually edit the response.php file as indicated in this forum. It only adds the image dimensions for the actual category image but not to the products. I use Jays page cache so not sure if this effects it.

Dean

Newbie

Posts

Joined
Tue Jun 17, 2014 2:42 pm

Post by Axel Wers » Wed Sep 16, 2015 7:50 am

IP_CAM wrote:This one works for OC Version, up to v.1.5.6.5_rc:
it's called: image_width_height_tags_156.xml
Hi, this generally works, but since I have installed this, in server error log I have lot of these logs:

Code: Select all

www.domain.tld [Tue Sep 15 06:52:50 2015] [error] [client xx.xx.xx.xx.] File does not exist: /root_path/image/cache/data/folder/title-500x500.jpg"+width="500"+height="500
What is wrong?

OC 2.3.0.2


New member

Posts

Joined
Fri Aug 22, 2014 3:59 pm
Who is online

Users browsing this forum: No registered users and 19 guests