So I'm trying to use getimagesize() to work out the aspect ratio of some images and size them accordingly, but it's producing an error in magento. Here is my code:
<? $brand_image_url = $mediaURL . 'catalog/category/' . $_subcategory->load($id)->getBrandLogo();
$brand_image_size = getimagesize($brand_image_url);
$brand_image_ratio = $brand_image_size[0]/$brand_image_size[1];
if($brand_image_ratio<100/48){ ?>
<img src="<?php echo $mediaURL; ?>catalog/category/<?php echo $_subcategory->load($id)->getBrandLogo(); ?>" alt="" height="48" /></span>
<?php }
else {
?><img src="<?php echo $mediaURL; ?>catalog/category/<?php echo $_subcategory->load($id)->getBrandLogo(); ?>" alt="" width="100" /></span> <?php
}?>
And here is the error it is producing:
Warning: getimagesize(http://dev.urbanrider.co.uk/media/catalog/category/agv-logo.jpg): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
in /home/uriderdev/web/app/design/frontend/urbanrider/default/template/wee_fpc/catalog/navigation/top.phtml on line 119
#0 [internal function]: mageCoreErrorHandler(2, 'getimagesize(ht...', '/home/uriderdev...', 119, Array)
#1 /home/uriderdev/web/app/design/frontend/urbanrider/default/template/wee_fpc/catalog/navigation/top.phtml(119): getimagesize('http://dev.urba...')
#2 /home/uriderdev/web/app/code/core/Mage/Core/Block/Template.php(241): include('/home/uriderdev...')
#3 /home/uriderdev/web/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/urbanr...')
#4 /home/uriderdev/web/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#5 /home/uriderdev/web/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml()
#6 /home/uriderdev/web/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#7 /home/uriderdev/web/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Text_List->_toHtml()
#8 /home/uriderdev/web/app/code/core/Mage/Core/Block/Abstract.php(582): Mage_Core_Block_Abstract->toHtml()
#9 /home/uriderdev/web/app/code/core/Mage/Core/Block/Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('topMenu', true)
#10 /home/uriderdev/web/app/design/frontend/urbanrider/default/template/page/html/header.phtml(81): Mage_Core_Block_Abstract->getChildHtml('topMenu')
#11 /home/uriderdev/web/app/code/core/Mage/Core/Block/Template.php(241): include('/home/uriderdev...')
#12 /home/uriderdev/web/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/urbanr...')
#13 /home/uriderdev/web/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#14 /home/uriderdev/web/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml()
#15 /home/uriderdev/web/app/code/core/Mage/Core/Block/Abstract.php(582): Mage_Core_Block_Abstract->toHtml()
#16 /home/uriderdev/web/app/code/core/Mage/Core/Block/Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('header', true)
#17 /home/uriderdev/web/app/design/frontend/urbanrider/default/template/page/1column.phtml(42): Mage_Core_Block_Abstract->getChildHtml('header')
#18 /home/uriderdev/web/app/code/core/Mage/Core/Block/Template.php(241): include('/home/uriderdev...')
#19 /home/uriderdev/web/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/urbanr...')
#20 /home/uriderdev/web/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#21 /home/uriderdev/web/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml()
#22 /home/uriderdev/web/app/code/core/Mage/Core/Model/Layout.php(529): Mage_Core_Block_Abstract->toHtml()
#23 /home/uriderdev/web/app/code/core/Mage/Core/Controller/Varien/Action.php(391): Mage_Core_Model_Layout->getOutput()
#24 /home/uriderdev/web/app/code/core/Mage/Cms/Helper/Page.php(132): Mage_Core_Controller_Varien_Action->renderLayout()
#25 /home/uriderdev/web/app/code/core/Mage/Cms/Helper/Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Urbanrider_CustomCms_IndexController), 'home')
#26 /home/uriderdev/web/app/code/core/Mage/Cms/controllers/IndexController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Urbanrider_CustomCms_IndexController), 'home')
#27 /home/uriderdev/web/app/code/core/Mage/Core/Controller/Varien/Action.php(420): Mage_Cms_IndexController->indexAction()
#28 /home/uriderdev/web/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#29 /home/uriderdev/web/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#30 /home/uriderdev/web/app/code/local/Mage/Core/Model/App.php(348): Mage_Core_Controller_Varien_Front->dispatch()
#31 /home/uriderdev/web/app/Mage.php(640): Mage_Core_Model_App->run(Array)
#32 /home/uriderdev/web/index.php(92): Mage::run('', 'store')
#33 {main}
It is a HTTP 403 (forbidden). You don't have permission to access /media/catalog/category/agv-logo.jpg on this server.
In other words, you could not get the image data from the provided URL.