Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento:在产品描述中添加自定义php代码_Php_Magento_Product - Fatal编程技术网

Magento:在产品描述中添加自定义php代码

Magento:在产品描述中添加自定义php代码,php,magento,product,Php,Magento,Product,我编写了一个php脚本,用于调整外部URL提供的jpeg图像的大小。 该脚本在我的服务器上运行良好,有一个测试页面,但Magento似乎不允许在产品描述中使用自定义php代码 有没有办法在描述中插入这段代码 <?php header('Content-Type: text/html; charset=utf-8'); $url_A = 'http:/...'; $url_B = 'http:/...'; $resizer_URL = 'http:/...'; echo '<a

我编写了一个php脚本,用于调整外部URL提供的jpeg图像的大小。 该脚本在我的服务器上运行良好,有一个测试页面,但Magento似乎不允许在产品描述中使用自定义php代码

有没有办法在描述中插入这段代码

<?php 
header('Content-Type: text/html; charset=utf-8');

$url_A = 'http:/...';
$url_B = 'http:/...';

$resizer_URL = 'http:/...';

echo '<a href="'.$url_A.'" target="_blank"><img class="scanA" src="'.$resizer_URL.'?url='.$url_A.'"/></a>
      <a href="'.$url_B.'" target="_blank"><img class="scanB" src="'.$resizer_URL.'?url='.$url_B.'"/></a>';

?>

脚本代码为:

<?php
// The file
$filename = $_GET['url'];

// Content type
header('Content-type: image/jpeg');

// Get new dimensions
list($width, $height) = getimagesize($filename);

$ratio = $height / $width;

$new_width = 580; 
$new_height = $new_width * $ratio;

// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

// Output
imagejpeg($image_p, null, 75);

//
imagedestroy($image_p);
imagedestroy($image);
?>


谢谢。

很可能这是不可能的。为什么不使用本机magento图像调整大小?因为我需要缩放外部图像(来自imageshak主机)。您知道实现此目的的技巧吗?您是否尝试过修改模板中的描述文件?(/app/design/frontend/default/your_theme/template/catalog/product/view/description.phtml)