How to call the image in the product view magento? - image

I want to call the image that loads into the larger view area of the magento product page.
In the product view page, I have more view images when clicked, it shows the image in the larger view, not in default pop up window. I want to call the full size image of whatever the image is loaded in the larger view area. Can someone tell me how do I do it?
I did some search and found
echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(163, 100);
But this gets only the image which was there by default. I want to be able to call any image that comes in the larger view area.

try this code
$this->helper('catalog/image')->init($_product, 'image')
this will get you the image on product view page.

ok I think this might save ur trouble. ITs Damn easy
Lets say ur main image area is <img id="main-image" src="main-image.jpg" />
<?php foreach ($this->getGalleryImages() as $_image): ?>
<li>
<a class="grouped_elements" href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(260,null) ?>"
title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" rel="group1">
<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(70,null) ?>"
width="70" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
</a>
</li>
<script type="text/javascript">
//<![CDATA[
jQuery("a.grouped_elements").click(function(){
$('#main-image').attr('src', this.attr('href'));
});
//]]>
</script>
Hope this should help ...

I think u must check the file
app\design\frontend\base\default\template\catalog\product\view
& its declared as in the
<block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/>
this file gives u the Main Image & also the Gallery Images. of course u'll get only enabled images.
so What I understand from the subsequent comments. u need these images in a fancybox. there has to be a slideshow thing previou next etc. right??
ok Here it is what u can do. Create a new file under
app\design\frontend\base\default\template\catalog\product\view\fancy.media.phtml
(or u can use ur theme folder instead of base/default)
in ur catalog.xml add this block under
<block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/>
<block type="catalog/product_view_media" name="fancy.media" template="catalog/product/view/fancy.media.phtml"/>
now in media.phtml u'll get all the images & there URLs. code the fancybox & pass the image url to it. &
& yeah don't forget to call this block in ur product page i.e.
app\design\frontend\base\default\template\catalog\product\view.phtml
by echo $this->getChilHtml('fancy.media')
I hope this must solve problem
UPDATE:
try this in fancy.media.phtml:
<?php foreach ($this->getGalleryImages() as $_image): ?>
<li>
<a class="grouped_elements" href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(260,null) ?>"
title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" rel="group1">
<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(70,null) ?>"
width="70" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
</a>
</li>
<?php endforeach; ?>
<script type="text/javascript">
//<![CDATA[
$("a.grouped_elements").fancybox();
//]]>
</script>
Please refer to the Docs of fancybox, fancybox how to
I think ur requirement is if somebody clicks on the More-views on product page it must get open in fancybox. Right?? so u can place this code in media.phtml also. no need to create a new file & no need to edit the catalog.xml.
If u make this working then feel free to accept my answer.

I got the desired result by adding a button on media.phtml
<a class="fullscreen" href="#image" onclick="document.getElementById('image').style.width='100%'; return false; " > <img src="<?php echo $this->getSkinUrl('images/zoom_full.jpg') ?>" alt="<?php echo $this->__('Full Screen') ?>" title="<?php echo $this->__('Full Screen') ?>" /></a>
<script type="text/javascript"> j(document).ready(function() {
j(".fullscreen").fancybox({ 'transitionIn': 'fade', 'transitionOut':
'none', 'overlayColor': '#fff', 'overlayOpacity':1,
'hideOnOverlayClick':false }); </script>

Related

Magento new products widget blurry

The small images of Magento's (1.9.0.1.) built in new products widget are blurry. I am using the default rwd theme and it does not seem to happen to other widgets such as recently viewed products.
It also displays on multiple rows instead of alongside each other.
Sorry I can't post pictures yet
Thanks!
I found a solution:
The image resizing is the 'new.phtml' file, but the theme RWD does not have this file.
Copy the file app/design/frontend/base/default/template/catalog/product/new.phtml
to app/design/frontend/rwd/default/template/catalog/product/ and change the size in line 35.
Old:
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135) ?>" width="135" height="135"
New:
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(272) ?>" width="272" height="272"
I changed to 272 to not get blurred.
This worked for me on magento 1.9.2:
Edit this file (if there isnĀ“t this file, copy from base/default theme):
app/design/frontend/rwd/default/template/catalog/product/new.phtml
And then replace the < a > tag with this code at line 35:
<?php $_imgSize=300; ?>
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize) ?>" width="<?php echo $_imgSize ?>" height="<?php echo $_imgSize ?>" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" />
Allright I found a solution:
I had to modify a line in new_grid.phtml in app/design/frontend/[rwd]/default/template/catalog/product/widget/new/content
Change the 85 to 210 in this line:
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(210) ?>" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" />

Linking intro image in Joomla 3.3.1

I would like to turn all intro images on the blog layout to links to the articles just as read more does.
Found this post here:
Joomla 3.1 intro image as read more link
The solution here is to replace the code in default_item.php from this:
<img
<?php if ($images->image_intro_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>
To this:
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>"><img
<?php if ($images->image_intro_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_intro_caption) .'"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/> </a>
Followed the instructions, added an override folder in my template, copied default_item.php to it and made the change to the code. Nothing happened. I then tried to change the same lines in the component folder just to see if the problem was with the template override, nothing.
Is there another way of doing this?
Thanks in advance,
Guy.
default_item.php is only used as part of the featured articles view. If you are using the blog view, then the files appear under com_content/views/category/
The image itself is generated under com_content/views/category/blog_item.php on line 35
<?php echo JLayoutHelper::render('joomla.content.intro_image', $this->item); ?>
Change this to (via your template override)
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>">
<?php echo JLayoutHelper::render('joomla.content.intro_image', $this->item); ?>
</a>

Header logo image shows at home page but not others

I'm using Mgto 1702 with hellowired template. I have various stores that follow the subfolder method (www.domaian.com/store). The header image logo and the Alt text file is in its folder. When you visit www.domain.com/store1 or /store2, etc the right logo appears on the home site header. When I click on any link to change pages (for example, a product page) the header shows correctly but NOT the image.
The header.phtml file includes an If that asks if it's the Home page (getIsHomePage()):?> but that doesn't really matter. I placed the code outside the If clause and the problem persists. I added a "trick" echo clause to follow the behaviour in all cases. The text appears but not the JPG.
Any suggestions?
Thanks
<?php // if ($this->getIsHomePage()):?>
<h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></h1>
<?php /*else:?>
<strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" />
<?php endif */?>
please remove the condition as shown above in the header.phtml page to get the same header in all the pages.

How to add product thumbnail image to order review page in Magento?

I am trying to show image thumbnail of products in order view page.
For this I am using this line
<img src="<?php echo Mage::helper('catalog/image')
->init($_item,'small_image')
->resize(50); ?>" width="50" height="50" alt="" />
in this file
template/sales/order/items/renderer/default.phtml
what I get is the blank image of magento, this one -->
On firebug I get the image url as below
src="http://my_Website.com/media/catalog/product/cache/1/small_image/50x/9df78eab33525d08d6e5fb8d27136e95/images/catalog/product/placeholder/small_image.jpg">
this is where that blank image is coming from.
Can anyone explain what's happening here and what's the possible solution.
Thank You very much in advance.
Try the codes given below:
First load the product
$_product = Mage::getModel('catalog/product')->load($_item->getProductId());
Then show the thumbnail where you want using the code given below
<img src="<?php echo Mage::helper('catalog/image')->init($_product, 'thumbnail')->resize(75, 75); ?>" alt="<?php echo $this->htmlEscape($_item->getName()); ?>" border="0" width="75" />
This code is working fine try :
if($_item->getProductType() == 'configurable') {
$_product = $_item->getProduct();
}else{
$_product = Mage::getModel('catalog/product')->load($_item->getId());
}
?>
<img src="<?php echo Mage::helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="" />
Make sure you have checked the appropriate radio button on the products media tab. There are three columns (Base Image, Small Image, Thumbnail) that need to be set to use that image as a thumbnail.

Magento display multiple product images on details page

I am uploading 2 images for each product. Only 2 no more, no less.
1st image is product base image and will be displayed on product details page.
I am using following line to display this image:
$_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(180, 300).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
echo $_helper->productAttribute($_product, $_img, 'image');
I am able to display the above image correctly.
Second image will be displayed in a pop up when a particular link is clicked. I do not want to display a gallery. Just want to display each image separately.
I think I found a way to retrieve array of images uploaded:
$productData = $_product->getData();
$secondImage = $productData['media_gallery']['images'][1];
Now, I am not sure how to display this image. I mean how to use helper, like I used for first image to make is display second image.
I've option to hardcode the complete path of image and use:
$secondImage['file'];
to display the image etc, but, I want to know if there is way, I can do it magento way ?
<?php foreach ($this->getGalleryImages() as $_image): ?>
<li>
<a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'scrollbars=yes,width=200,height=200,resizable=yes');return false;">
<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(68,68); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"/>
</a>
</li>
<?php endforeach; ?>
Code lifted from:
http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/catalog/adding_lightbox_to_magento_v2
Note exactly the answer but obviously you can remove the foreach and simply supply the array's index if you know your only going to have one file.

Resources