cannot view the database image into the table in codeigniter - 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

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;?>

Change Magento image size on search results page

I have changed the size of the images on the category pages from 135px to 400px. It now shows 3 columns with 400px images. This works fine! BUT I want the search result page to look the same as the category page. It already has 3 columns and the images are displayed as 400px. The only problem is that it still loads a 135px small image. Now the images are very blurry. How do I change this so it will load a 400px image?
Thank you
By default Magento displays the search results through the template;
app/design/frontend/YOURPACKAGE/YOURTHEME/template/catalog/product/list.phtml
I you wanted to change that then the best thing you could do is follow the advice in the following link and designate a custom template to display your results by copying and renaming the list.phtml file;
Magento design update to replace list.phtml on search results page only
You could then customise it however you want. The section you would change is the following code which, as you can see ( the ->resize(135) part) is resizing your small product image to 135px. Change that to 400 and assuming the small image itself is not smaller than 400px wide then it want be pixellated.
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
This can only be done through CSS. The CSS depends on the theme your using.

how to display uploaded image file name from database when going to edit(Codeigniter)

I know how to upload image to database and show the image name in the view. Now I need to know how I display image name when going to Edit that Database.
My Create_Edit_Floor.php ---->
<tr><!--Edit by Yesh | Upload floor image-->
<td width='20%'>Floor Map <span class='star'> * </span></td>
<td width='5%'>:</td>
<td width='20%'><?=form_upload('emergency_img')?></td>
<td><span id="error"><?=isset($upload_file_error) ? $upload_file_error : ''; ?></span></td>
</tr><!--Edit by Yesh-->
I think, I need to pass something inside the <?form_upload?>
First, if you are saving images into db you're doing it wrong.
then, if you really need to save them inside db, you have to run a query to the db to get the images as SQL result and then show them like (i guess you are saving the binary image into db)
<img src="data:image/jpg;base64,<?php echo base64_encode($row->image); ?>" />
I really suggest you to not save images into the db, usually i save the filename but not the image itself, cause images should be linked to let the browser cache them
just my 2 cents

Display attribute image instead of text

I figure out how to show attribute in category of product list, what I need is to display an image instead of text.
Eg. I have an attribute text ASUS and a image located in media/brands/ named asus.gif or instead of Western-Digital display image located in media/brands/western-digital.gif.
I hope you understand
What you want to do is
<img src="<?php echo $this->getMediaUrl(); ?>brands/<?php echo strtolower($_product->getManufacturer()); ?>.png" />
getManufacturer may be the attribte, change it, if needed.
I found the solution:
<?php $brand=$_product->getAttributeText('manufacturer');
echo '<img style="float: right; margin: 2px;" src="/media/catalog/brands/'.str_replace(' ', '_',$brand).'.gif" alt="'.$brand.'">' ?>
If your attribute is a dropdown one you could add a new column in the table eav_attribute_option_value and in the "manage options/labels" tab of the manage attribute page in the admin panel. For each option values, next to each store traduction, you could store the name of your image and retrieve it in your templates.. it require some development but it's doable and easy to administrate.
Or the quick and dirty way : use the admin label string, lowercase it and clean to retrieve an image related filename
In the Magento 1.7.0.2 you can accomplish this in a very easy way...
All you do is create a new attribute, and select 'media image' from the 'catalog input type..' dropdown.

echoing a image in view page from DB

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

Resources