ScottShipley Posted January 29, 2009 Share Posted January 29, 2009 i've got a slight problem with image sizes on admin pages. in the configuration section i've got my small image width set to 100 and the height left blank so that the aspect ratio stays the same, this works fine on the main site with all the images displaying perfectly. However in the admin section images are being displayed at their full size, the only way to get them to display at the desired size is to have the width and the height populated. Does anyone know why the admin section responds diferently to the main site and how i can make it respond in the same way as the main site as i really need the images to display smaller in admin. Thanks Scott Link to comment Share on other sites More sharing options...
ScottShipley Posted February 7, 2009 Author Share Posted February 7, 2009 bump Scott Link to comment Share on other sites More sharing options...
germ Posted February 7, 2009 Share Posted February 7, 2009 Here's the answer to "Why?" Look at the code in /catalog/includes/functions/html_output.php //// // The HTML image wrapper function function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') { if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) { return false; } // alt is added to the img tag even if it is null to prevent browsers from outputting // the image filename as default $image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"'; if (tep_not_null($alt)) { $image .= ' title=" ' . tep_output_string($alt) . ' "'; } [color="#FF0000"] if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) { if ($image_size = @getimagesize($src)) { if (empty($width) && tep_not_null($height)) { $ratio = $height / $image_size[1]; $width = intval($image_size[0] * $ratio); } elseif (tep_not_null($width) && empty($height)) { $ratio = $width / $image_size[0]; $height = intval($image_size[1] * $ratio); } elseif (empty($width) && empty($height)) { $width = $image_size[0]; $height = $image_size[1]; } } elseif (IMAGE_REQUIRED == 'false') { return false; } }[/color] if (tep_not_null($width) && tep_not_null($height)) { $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"'; } if (tep_not_null($parameters)) $image .= ' ' . $parameters; $image .= '>'; return $image; } Now look at the same code on the admin side: //// // The HTML image wrapper function function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') { $image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"'; if (tep_not_null($alt)) { $image .= ' title=" ' . tep_output_string($alt) . ' "'; } [color="#FF0000"] if (tep_not_null($width) && tep_not_null($height)) { $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"'; }[/color] if (tep_not_null($parameters)) $image .= ' ' . $parameters; $image .= '>'; return $image; } The admin does no size recalculation. :o Changing the tep_image code in /admin/includes/functions/html_output.php to the code below may work. THIS IS NOT MEANT AS A REPLACEMENT FOR THE WHOLE FILE. JUST THAT ONE FUNCTION. BACKUP BEFORE MAKING ANY EDITS. YOU BROKE IT - YOU BOUGHT IT. //// // The HTML image wrapper function function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') { $image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"'; if (tep_not_null($alt)) { $image .= ' title=" ' . tep_output_string($alt) . ' "'; } if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) { if ($image_size = @getimagesize($src)) { if (empty($width) && tep_not_null($height)) { $ratio = $height / $image_size[1]; $width = intval($image_size[0] * $ratio); } elseif (tep_not_null($width) && empty($height)) { $ratio = $width / $image_size[0]; $height = intval($image_size[1] * $ratio); } elseif (empty($width) && empty($height)) { $width = $image_size[0]; $height = $image_size[1]; } } } if (tep_not_null($width) && tep_not_null($height)) { $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"'; } if (tep_not_null($parameters)) $image .= ' ' . $parameters; $image .= '>'; return $image; } If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
ScottShipley Posted February 8, 2009 Author Share Posted February 8, 2009 nope that didn't work, images are still showing at their full size in admin Scott Link to comment Share on other sites More sharing options...
germ Posted February 8, 2009 Share Posted February 8, 2009 I just did the best with what I had to work with. :huh: If you said what version of osC you have and exactly where the problem lies I may be able to help further. No promises other than I'll look into it (if provided more info) If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
ScottShipley Posted February 8, 2009 Author Share Posted February 8, 2009 hey its no problem, it was good of you to try! I'm using version 2.2 RC2a ok i'll try to be as detailed as i can with the issue but basically every image shows at its full siza in admin no matter what section of admin you are in. If i change the sizes in the configuration so that both width and height are populated (i only populate width) then the images do resize to those sizes but with just one populated it displays them at full size, not taking the settings into account at all. I hope somebody has an answer. Thanks Scott Link to comment Share on other sites More sharing options...
germ Posted February 8, 2009 Share Posted February 8, 2009 In your admin, find a place where the image is full size where it shouldn't be. Then find that code in the HTML source of the page. Does the HTML have the width="xx" height="xx" parameters for the image? :unsure: Off the top I'd suggest changing this: if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) { to if ( empty($width) || empty($height) ) { In the new code I posted. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
germ Posted February 8, 2009 Share Posted February 8, 2009 After further contemplation, I realized that won't work. It's in the code. On the pages where the image is full size it must be calling tep_image without the image size parameters. It needs to be something like this: tep_image(DIR_WS_CATALOG_IMAGES . $products_image_name, $pInfo->products_name, [color="#FF0000"]SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT[/color]) There is no "magic bullet" to fix it. :blush: That's all I can think of that would cause it and fix it. If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
ScottShipley Posted February 9, 2009 Author Share Posted February 9, 2009 After further contemplation, I realized that won't work. It's in the code. On the pages where the image is full size it must be calling tep_image without the image size parameters. It needs to be something like this: tep_image(DIR_WS_CATALOG_IMAGES . $products_image_name, $pInfo->products_name, [color="#FF0000"]SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT[/color]) There is no "magic bullet" to fix it. :blush: That's all I can think of that would cause it and fix it. It already has that in the code, here's an example of the code tep_image(DIR_WS_CATALOG_IMAGES . $prod_row['products_image'], $prod_row['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) and this is how it looks when you view source <img src="/catalog/images/ebc/Greenstuff.jpg" border="0" alt="EBC Brakes - PEUGEOT 205 1.7 D 85-96 Greenstuff Pads - Front" title=" EBC Brakes - PEUGEOT 205 1.7 D 85-96 Greenstuff Pads - Front "> now if i change the settings so that both fields are populated i get this in the source <img src="/catalog/images/ebc/Greenstuff.jpg" border="0" alt="EBC Brakes - PEUGEOT 205 1.7 D 85-96 Greenstuff Pads - Front" title=" EBC Brakes - PEUGEOT 205 1.7 D 85-96 Greenstuff Pads - Front " width="100" height="100"> hope that doesn't confuse you as much as it confuses me! Scott Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.