ZendFramework 图像未加载 [英] ZendFramework images not loading

查看:20
本文介绍了ZendFramework 图像未加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ZendFramework 中开发了一个网站,主页上有两张社交图片.当我第一次加载页面时,图像不存在,但是,如果我然后单击一个链接,图像就会出现,如果我再单击另一个链接进一步进入网站,它们再次消失,图像位于布局文件中的 div 中,它们应该是一直以来,布局文件中的所有其他内容都与这些无关.我一直在努力解决一个问题,即尝试从标签的 src 属性中的数据库回显图像路径,但无法使其工作,然后我意识到这正在发生,我假设它与社交图像问题有关,因为我希望显示数据库图像的页面也没有社交链接..

I have a site I am developing in the ZendFramework and I have two social image pictures on the homepage. When I first load the page the images aren't there, however if I then click a link the images appear if I then click another link further into the site they disappear again, the images are in a div in the layout file they should be there all the time everything else in the layout file is apart from these.. I have been struggling on an issue of trying to echo image paths from a database in the src property of the tag and couldn't get it to work then I realized this was happening and I am assuming it has something to do with the social images problem as the page where I want the database images to appear doesn't have the social links either..

对不起,我真的不知道如何解释这个问题,希望它没问题,如果您需要有关此事的更多信息,请不要犹豫,问!

Sorry for the rant I just don't really know how to explain the problem, hope it comes across ok, if you need any more information on this matter don't hesitate to ask!

提前致谢!

瑞克

推荐答案

当你回显图像标签的 src 属性的图像路径时,你应该使用 baseUrl helper 所以路径总是绝对并引用您的基本网址.

When you echo the path to the image for the src attribute of the image tag, you should be using the baseUrl helper so the path is always absolute and references your base URL.

例如,您可以调用 <?php echo $this->baseUrl('images/test.png') ?> ,这将导致类似 /zendapp/public/images/images.

For example, you would call <?php echo $this->baseUrl('images/test.png') ?> and that will result in something like /zendapp/public/images or /images.

我怀疑发生的事情是图像标签看起来像这样:<img src="images/thepic.png"/>.您应该确保所有图像、CSS、Javascript 引用等都使用绝对路径,如 /images 并避免 ../images./images, 或 images 等.

I suspect what is happening is the image tag looks something like this: <img src="images/thepic.png" />. You should make sure all images, CSS, Javascript references etc all use absolute paths like /images and avoid ../images, ./images, or images and the like.

希望有所帮助.

这篇关于ZendFramework 图像未加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆