Image file was not found for custom attribute - magento

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

Related

Magento 1.9.3 Display alternative image on hover on category page

I want to display an alternative image on hover on category page by assigning it in Product Information -> Images. I have created an attribute hover_image with the parameters Scope-Global, Catalog Input Type-Media Image, Apply to All Product Types. Added the attribute to the set. What should I do next? Thank you
To show the alternative hover image on category page. You need to make changes in Product Listing template in your current theme template/catalog/product/list.phtml.
As you have already created the media type attribute 'hover_image'. So you need to fetch hover_image type image like below:
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'hover_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'hover_image'), null, true) ?>" />
Now you need to use javascript to apply hover effect on product images to hide the original image and show hover image.

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

change product images path in magento site

In Product view page, image is serving from this path : link
/media/catalog/product/cache/1/image/350x350/9df78eab33525d08d6e5fb8d27136e95/b/a/ball.jpg
it's using 350x350 size
but i wanted to serve from this path : link2
media/catalog/product/cache/1/image/850x850/9df78eab33525d08d6e5fb8d27136e95/b/a/ball.jpg
I need 850x850 size.
we are using : <?php echo $dexxtz->getImageFeatured($this->helper('catalog/image')->init($_product, 'image')); ?>
You need to tell Magento about the resolution for which you want to pick the image, resize will help you in your case:-
$this->helper('catalog/image')->init($_product, 'image')->resize(850, 850);

how to check availability of custom image attribute

i know this question is just being asked many times but i have some problem in custom image attribute i create new custom image(image180) attribute with magento admin & using this code to get image in frontend & this code working properly & showing image how to correct this & thanks in advance
<div class="rotate"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'image180'); ?>"></div>
but i have to check if this image is avabile then run the code if not avaible don't run this code because if this attribute not avaible fir specific product the product page is not load & show the error & i am using this code to check avability of custom image but not working what going wrong
<?php if ($_product->getimage180()):?>
<div class="rotate"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'image180'); ?>"></div>
<?php endif;?>
Please you try this
getImage180()):?>
helper('catalog/image')->init($_product, 'image180'); ?>">
You can try
if($_product->getData('image180')!=null && $_product>getData('image180')!='no_selection')
instead of if($_product->getimage180())
And if you use $_product->getimage180() then also it is invalid.
It should be $_product->getImage180()

How to output the thumbnail of the featured image Wordpress?

I want to output the thumbnail of the featured image of a post inside one of my widgets? How can I do that inside the loop, in Wordpress. I'm using version 3.3.1
you can use
<?php the_post_thumbnail(); ?>
or if you want only the image src and not all the wordpress's html output, use this:
<?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?>
references:
http://codex.wordpress.org/Function_Reference/the_post_thumbnail
http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail

Resources