echoing a image in view page from DB - image

i'm using Ci and i have a form that saves image in a folder. The name of the image is saved in my DB. I want to echo this image.i can retrieve the image name from Db but when i'm echoing this the image it is not showing. I think my controller and model is working fine but there is something wrong with my view.
the part where i'm echoing the image:
<img src="<?php echo base_url();?>uploads/$info[0]->image"></img>
info is the array where the information from the DB(like image name) is saved.
I cannot find my mistake.please help.

I think it's because you're using $info[0]->image outside the PHP tags.
It should be like this:
<img src="<?php echo base_url().'uploads/'.$info[0]->image; ?>" />
One more mistake is how you write the HTML tag IMG

Related

Image file was not found for custom attribute

I am using magento 1.9.1
I have added media attribute name 'offer_image' in images.
I have also set in attribute set and added image to this attribute in product page.
When I try to get this attribute image on frontent it show error
"Image file was not found"
I am using this code to get image
$this->helper('catalog/image')->init($_product, 'offer_image')->resize(50);
This code work fine if I use thumbnail or small_image.
How should I get custom attribute image, what is wrong with code.
Try to load a product first (looks like you're taking it from a collection):
$product = Mage::getModel('catalog/product')->load($_product->getId());
$this->helper('catalog/image')->init($product, 'offer_image')->resize(50);
<?php if ($_product->getOfferImage() && ($_product->getOfferImage() != 'no_selection')):?>
<img src="<?php echo $_product->getOfferImage();?>">
<?php endif;?>

cannot view the database image into the table in codeigniter

I cannot view my image in the table which name is store in the database.It shows broken image even though the image is correct.
<td><img id="img" src="<?php echo base_url();?>uploads/<?php echo $rows->customer_image;?>" width="30px" height="30px"/></td>.
Check on your base_url, is has correct value or not ?
Replace from your src value into this (more readable) :
<?php echo base_url('uploads/'.$rows->customer_image); ?>
Check your database as well as image in your uploads directory, is exist or not ?
Additional note : use alt attribute in your img element for giving text if your image won't appear. Hope it helps

Display images on Joomla

I just can't seem to display my images in Joomla. Here is an example of my code:
<a href="/img/Zaalvoetbaltornooi SKLA 2.jpg" rel="shadowbox"><img src="/img/Zaalvoetbaltornooi SKLA 2.jpg" width="200px" height="250px" alt="Fuif SLKA" id="eventskla" />
As you can see it also uses shadowbox which doesn't work. Here is a screenshot of my folders:
And a screenshot of templateDetails.XML:
Can anyone tell me what I'm doing wrong? Options in Joomla wrong or wrong code?
I found it: I used the 'normal' way of coding but the code you have to use is this one:
<img src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template; ?>/images/myimage.png" alt="Custom image" class="customImage" />
Then simply change the map and image (e.g. /img/base.jpg) you're using in Joomla.
Just as a friendly tip, I like to create a variable called "tpath", which is the path to the template. It makes the paths I have to write in the template much shorter. I just create the variable in the Head like so:
$tpath = $this->baseurl.'/templates/'.$this->template;
Now all you have to do to write a template URL is:
href="<?php echo $tpath; ?>/...

CodeIgniter - Binary image not being displayed

I've built a function on class Image that retrieves or should retrieve me the image in a binary format. However I just get the error icon when I call that controller method.
I need this done this way, because the images are being sent to an iOS and Android app.
The path of the image is correct (I've double checked it)
I'm using CodeIgniter 2.1.3 and my code looks like this
$images = $this->image->getImageById($database,$id);
$data = fopen($images->path, 'rb');
header('Content-type: image/jpeg');
fpassthru($data);
Any idea on how can I achieve this?
Thank you
I thing you are looking for something like this.
http://www.ehow.com/how_8745742_convert-binary-data-using-php.html
I think this may help you. After getting the result in your model file in an array. In your example $images.
In the view file display it like this <img src="<?php echo $images['path'] ?>" />

Magento Commerce - Use new image type on front page

I added a new image type to the image uploads called featured_banner_image. If a product is marked as featured I have a jQuery slider that will pull the featured_banner_image on the front page.
The problem is that
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'featured_banner_image')->resize(135) ?>">
does not work. What code can I pull to grab my new image?

Resources