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!
Thanks in advance!
Rik
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.For example, you would call
<?php echo $this->baseUrl('images/test.png') ?>
and that will result in something like/zendapp/public/images
or/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
, orimages
and the like.Hope that helps.
If don't wont use native view helper function
$this->baseUrl()
. Just add slash before image url<img src="/images/thepic.png" alt="Some description" width="" heigth="" />