我写了一个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);
?>
感谢。