0

以下のコードを使用して、ラベルごとに製品画像を表示しています。

$productId = $this->getProduct_id(); 
$_product = Mage::getModel('catalog/product')->load($productId);


src="<?php echo $_product->getMediaGalleryImages()->getItemByColumnValue('label', 'mylabel')->getUrl(); ?>"

画像のサイズを変更するにはどうすればよいですか?

4

1 に答える 1

1

// 画像名

$image = "";

    // actual image path

//$imageUrl = Mage::getBaseDir('media'). DS .'テスト'. DS .$イメージ;

あなたの場合、画像のURLは

$imageUrl="<?php echo $_product->getMediaGalleryImages()->getItemByColumnValue('label', 'mylabel')->getUrl(); ?>"


    // Give resized image path to be saved
    // here, the resized image will save in media/test/resized folder

$imageResized = Mage::getBaseDir('media'). DS .'テスト'. DS .'サイズ変更'. DS .$イメージ;

    // image will resize only if the image file exists and the resized image file doesn't exist



 if (!file_exists($imageResized) && file_exists($imageUrl))
    {
        $imageObj = new Varien_Image($imageUrl);
        $imageObj->constrainOnly(TRUE);
        $imageObj->keepAspectRatio(TRUE);
        $imageObj->keepFrame(FALSE);
        $imageObj->resize(300, null);
        $imageObj->save($imageResized);
    }

これがあなたを助けることを願っています

于 2013-10-16T11:49:17.190 に答える