Search code examples
zend-framework2assets

how to use html img


I have the following folder structure in my zend framework 2 tutorial project in Ubuntu:

/zf2tutorial
    /module
        /Album
            /view
                /album
                    /album
                        myImage.png
                        index.phtml

in my index.phtml code I have a line such as this:

<img alt='SMALLIMG' src='myImage.png'/>

this does not work.

If I change the myImage.png to be http://www.someurlhere.com this works fine.

How do I load in myImage.png instead? I tried giving it the direct URL:

/home/myUsername/NetBeansProjects/zf2tutorial/module/Album/view/album/album/myImage.png

I've also tried doing the following:

../myImage.png

but neither of these worked.

Also please note, it has to be a bad path (I must be doing something wrong here) because the broken image icon shows up... indicating there is a linking problem here.. the direct URL is copy pasted from the properties section of the image itself..


Solution

  • It's not a problem of image or path. You are trying to make an impossible thing.

    You certainly define in your virtualhost configuration that the documentRoot is your public directory.

    That means your web server will give access to resources located from this public directory.

    You have to put your resources from this public path (css, images..) or you can define a symbolic link if you allow followingSymlinks.

    Hope this helps.