2

I try to load url image to be display in slider.

I use this function :

Mage::helper('catalog/image')
            ->init($product, 'small_image', $file)
            ->resize($w, $h);

It works partially, on some products, no problem but for some others the website crash. I mean after this line no more html code are generated. There is no error on nginx, php, exception.log or system.log.

So I try to do :

Mage::helper('catalog/image')
            ->init($product, 'WTFiswrong', $file)
            ->resize($w, $h);

Here I have errors everywhere (It's normal because it's true) : "Fichier image introuvable." (translate : image not found)

So what's happen in the first case ?

UPDATE :

<?php

define('MAGENTO_ROOT', getcwd());
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;

Mage::app();

$id = 397;

$x = 200;

$y = 100;
$product = Mage::getModel('catalog/product')->load($id);

echo Mage::helper('catalog/image')->init($product, 'small_image')->resize($x, $y);

exit (0);

?>

This display nothing, return 500 error code with no error in error log.

UPDATE 2 :

It seems to be a memory issue, problem solved.

1

Make sure you have your default images set up first. Log in to the admin area and go to System > Configuration > Catalog > Product Image Placeholders

0

This works:

 Mage::helper('catalog/image')->init($product, 'small_image')->resize($x, $y);

$file is not needed.

[EDIT]

Mage::app();

$id = [your product id as in entity_id];

$x = 200;

$y = 100;
$product = Mage::getModel('catalog/product')->load($id);

echo =  Mage::helper('catalog/image')->init($product, 'small_image')->resize($x, $y);

exit (0);
  • Hi Wolfie, Unfortunately it's not working, I have the same issue. – Inglebard Mar 6 '15 at 15:45
  • What happens if you just put together a script in your web root, e.g. test.php with (see edited answer) and then point your browser at yoursite.com/test.php - do you get to see a URL to a cached image? – Henry's Cat Mar 6 '15 at 16:10
  • I modify some part of your code, It displays nothing, return 500 error code but without errors. – Inglebard Mar 6 '15 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.