我一直在尝试使用joomla中的imagecreatefrompng
函数。我在components/mycomponent/views/imgview/tmpl/default.php中使用该函数我必须传递图像url administrator/components/mycomponent/images/image .png到它。
我试过很多方法。但这些都不起作用。是否有特定的方式将url传递给该函数。ie。我应该把它作为
传递吗?$img = imagecreatefrompng('administrator/components/mycomponent/images/img.png');
或
$img = imagecreatefrompng('http://localhost/joomla/administrator/components/mycomponent/images/img.png');
或
$img = imagecreatefrompng('/var/www/joomla/administrator/components/mycomponent/images/img.png');
如果您查看一些默认模板文件,Joomla通常更希望您使用JPATH_ROOT
全局变量,以确保您始终从站点根目录工作,如下所示:
$path = JPATH_ROOT . '/administrator/components/mycomponent/images/img.png';
$img = imagecreatefrompng($path);
编辑:忘记了第一个斜杠。