Symfony url for image


Symfony url for image

我需要获得图像的最终url,将其设置为JQuery Datepicker输入的参数。声明DatePicker的方法是:

$("#myInput").datepicker({
    showOn: "button",
    buttonImage: "<url-for-the-image>",
    buttonImageOnly: true
});

我知道在symfony中,图像(默认情况下)位于/web/images目录中,可以使用sfConfig::get('sf_web_dir').'/images'访问该目录。

问题是,这个函数返回的内容类似于/var/www/.../web/images,而不是http://-IP-ADDRESS-/.../web/images

如何在我的图像目录中找到正确的图像url?非常感谢!

好的,解决了!只需使用此Symfony函数:image_path('my-image.png');这将返回图像的路径!