I posted Qphorias code into response.php
Code: Select all
if ($this->level) {
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') {
Code: Select all
if (count($info) == 3 && isset($info[1][0]) && $info[1][0] == 'src') {
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]);
}
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;
}
}
}
?>
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?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 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 !
Life is for the taking. It's everything else you need to pay for.
Anne Makes Lovely Candles
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
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
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 .
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
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?
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>
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.
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.
Dean
Hi, this generally works, but since I have installed this, in server error log I have lot of these logs: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
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
OC 2.3.0.2
Users browsing this forum: No registered users and 37 guests