I'm new to Zend Framework, so forgive me if this is a basic question, but I'm having a heck of a time, displaying an image retrieved from the database.
Edit: I basically can't access any resource from the /public/ folder. I'm guessing the front controller is redirecting src requests inside <link>
tags and <img>
tags. Everytime I search, I see people having problems accessing images outside the /public/ folder... but they seem to be fine as long as they're stored under the /public folder. What am I doing wrong?
I've got the following code in a view partial:
<?php
$user = Zend_Layout::getMvcInstance()->getView()->user;
?>
<section class="one-fifth first sidebar_profile">
<div class="one-fifth first about_img"><img src="<?php if($user->picture){echo '/public/img/users/small_thumbs/'.$user->picture;}else{echo "#";} ?>" alt="name"/>
<p class="name"><?php if($user) {echo $user->username; } else { echo "Username";} ?></p>
Doing a dump of $user
gives me the following:
object(Zend_Db_Table_Row)[70]
protected '_data' =>
array
'userID' => string '22' (length=2)
'username' => string 'test' (length=4)
'firstName' => string '' (length=0)
'lastName' => string '' (length=0)
'email' => string '[email protected]' (length=18)
'password' => string '098f6bcd4621d373cade4e832627b4f6' (length=32)
'picture' => string '4fa3072fe09a5.jpg' (length=17)
'verified' => string '1' (length=1)
'confirm_key' => null
'admin' => null
It goes on quite a while, but the point is the file is there. Looking at the source code from the page that's rendered, the line in question is rendered as:
<img alt="name" src="/public/img/users/small_thumbs4fa3072fe09a5.jpg">
Should I be using some sort of view helper to display this? I've searched and searched, and couldn't find one.
public
in your frontend urls; thepublic
would be part of the virtual host definition. – David Weinraub@import
– Brian Vanderbusch.htaccess
at the web root will bypass the framework for any files/directories that actually exist. If you enterhttp://yourhostname/img/users/small_thumbs4fa3072fe09a5.jpg
into the browser, you don't get the image? Another thought: Issmall_thumbs
a folder? If so, you're missing a slash; the correct url would be/img/users/small_thumbs/4fa3072fe09a5.jpg
– David Weinraub