0

所以我试图使用 getimagesize() 来计算一些图像的纵横比并相应地调整它们的大小,但它会在 magento 中产生错误。这是我的代码:

<? $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
}?>

这是它产生的错误:

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}
4

1 回答 1

1

这是一个 HTTP 403(禁止)。您无权访问此服务器上的 /media/catalog/category/agv-logo.jpg。

换句话说,您无法从提供的 URL 中获取图像数据。

于 2014-02-19T12:41:03.953 回答