Magento 1.9 Image Url without cache - php

I am new with Magento and I couldn't find a clear answer about this. In the browser, my site images show like this:
www.example.com/shop/media/catalog/product/cache/1/image/820x/040ec09b1e35df139433887a97daa66f/i/m/image-name.jpg
I would like my images to show like this:
www.example.com/shop/media/catalog/product/i/m/image-name.jpg
I don't resize my images or use watermarks.
On media.phtml (app/design/frontend/mytheme/default/template/catalog/product/view/media.phtml), I have this code:
<div class="img-holder<?php if($labelsoptions['labelsorder'] == 'sale_new'):?> labels-sale-new<?php endif; ?>">
<?php if(($fancy['fancybox_status']==1) and ($fancy['fancybox_product']==1)): ?>
<i class="fa fa-search"></i>
<?php endif; ?>
<a id='zoom' class="cloud-zoom" data-zoom="showTitle: false, adjustX: -5, adjustY:-5, tint: '#fff', tintOpacity:0.6, position:'inside'" href="<?php echo $this->helper('catalog/image')->init($_product, 'image'); ?>"><?php
$_img = '<img id="image" src="' . $helpImg->getImg($_product, 'image', $imgSize, null) .'"" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
echo $_helper->productAttribute($_product, $_img, 'image');
?></a>
<?php echo MAGE::helper('MyThemeOptions')->getProductLabels($_product, 'new'); ?>
<?php echo MAGE::helper('MyThemeOptions')->getProductLabels($_product, 'sale'); ?>
</div>
I replaced this:
<a href="<?php echo $this->helper('catalog/image')->init($_product, 'image'); ?>"
with this code I found in google, but nothing happens:
<a href="<?php echo Mage::getSingleton('catalog/product_media_config')->getBaseMediaUrl().$this->getProduct()->getImage(); ?>"
I appreciate your help. Thanks.

Here is the way to get full size product image:
$fullImgUrl = Mage::getUrl('media') . 'catalog/product' . $_product->getImage();
btw, you can use browser inspect feature to know what is outputted

Related

How to call php bloginfo directory wordpress on a function

How to call PHP blog info 'wordpress code' inside my php function, on my image src.
<?php
$show_social = get_option('theme_show_social_menu');
$sl_faceook = get_option('theme_facebook_link');
if($show_social == 'true')
{
?>
<ul class="social-nav">
<div class="footer_social">
<?php
echo ($sl_faceook) ? '<img src="<?php bloginfo('stylesheet_directory'); ?>/images/fold/GGGGG-03.png " alt="facebook" /><a target="_blank" href="'.$sl_faceook.'"></a></li>' : '';
?>
</div><!--//footer_social-->
</ul>
You can try this code:
<ul class="social-nav">
<div class="footer_social">
<?php if($sl_faceook):?>
<li><a target="_blank" href="<?php echo $sl_faceook ?>"><img src="<?php echo bloginfo('stylesheet_directory'); ?>/images/fold/GGGGG-03.png" alt="facebook" /></a></li>
<?php endif; ?>
</div><!--//footer_social-->
</ul>
If you are using a child theme, you should use this or if you are not using a child theme get_template_directory but, I would suggest to use a child theme.
<?php
$show_social = get_option('theme_show_social_menu');
$sl_faceook = get_option('theme_facebook_link');
if($show_social == 'true')
{
?>
<ul class="social-nav">
<div class="footer_social">
<?php
echo ($sl_faceook) ? '<img src="' . get_stylesheet_directory_uri() . ' /images/fold/GGGGG-03.png" alt="facebook" width="150px" height="150px" /><a target="_blank" href="'.$sl_faceook.'"></a></li>' : '';
?>
</div><!--//footer_social-->
</ul>

Is there a way to display youtube video instead of product image in Opencart?

I am trying to make changes to product page of Opencart where I am trying to show a video instead of the product image. If I hardcode the video id I am able to play the video instead of the product image. but, I plan to take the video id from database table oc_product and new column u_tube_url to be defined and linked. currently in the default theme the path of image is defined in the image column. but, I want to give youtube videoid instead of image path.
I think the changes has to be done in product page at
/catalog/view/theme/default/template/product/product.tpl
<?php if ($thumb || $images) { ?>
<ul class="thumbnails">
<?php if ($thumb) { ?>
<li>
<a class="thumbnail" href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>">
<img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" />
</a>
</li>
<?php } ?>
</ul>
<?php } ?>
I also think some changes might be required at /catalog/controller/product/product.php
I added a db column in product description table. then...
I made changes to include video instead of product image.
Step 1
Open file: catalog/view/theme/default/template/product/product.tpl
Find :
<li><a class="thumbnail" href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>"><img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" /></a></li>
Replace:
<li><a <embed src="http://www.youtube.com/embed/<?php echo $url_id; ?>?autoplay=0&rel=0" width="360" height="240"></embed></a><embed src="http://www.youtube.com/embed/<?php echo $url_id; ?>?autoplay=0&rel=0" width="360" height="240"></embed></li>
Step 2
Open file: admin/model/catalog/product.php
Add to :
url_id = '" . $this->db->escape($value['url_id']) . "',
Step 3
Open file: catalog/controller/product/product.php
Find :
$data['heading_title'] = $product_info['name'];
Add after :
$data['url_id'] = $product_info['url_id'];
Step 4
Open file: catalog/controller/product/product.php
Find :
'special' => $special,
Add after :
'url_id' => $result['url_id'],
Step 5
Open file: catalog/model/catalog/product.php
Find :
'description' => $query->row['description'],
Add after :
'url_id'=> $query->row['url_id'],

Joomla 3.1 the full article image to be clickable (to self image url)

I find this com_content/views/article/tmpl/default.php I created a template override and here is the code:
<?php if ($params->get('access-view')):?>
<?php if (isset($images->image_fulltext) && !empty($images->image_fulltext)) : ?>
<?php $imgfloat = (empty($images->float_fulltext)) ? $params->get('float_fulltext') : $images->float_fulltext; ?>
<div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image">
<img
<?php if ($images->image_fulltext_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_fulltext_caption) . '"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_fulltext); ?>" alt="<?php echo htmlspecialchars($images->image_fulltext_alt); ?>"/> </div>
<?php endif; ?>
Before img tag how to form, modify this php code to be clickable the image to self url:
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>"> <img
Here is the resolution:
<a href="<?php echo JURI::root().$images->image_fulltext; ?>">
Now the image is "clickalble" to self url
JURI::root() > your webpage url (like: something.com)
$images->image_fulltext > in joomla 3.1 you can choose an image what is displayed when you click to readmore, ie when you read the full article, that image have an url, like: /images/stories/freshsite/something.jpg
This php code combines these two code, to be: something.com/images/stories/freshsite/something.jpg > when you click on the image, only this image will shows in you browser :)

Show specific logo for user group in Joomla 3

I can't seem to see a logical way to do this, I've tried many different functions, some of which i get blank page errors, other which it seems to work but just skips and goes to the else function everytime.
In a nutshell, I'm trying to have it so that certain logos will be displayed depending on the User Group ID.
At the moment the code below is producing a blank error page, and I can't see why.
Could anyone help me with this? Joomla 3.1 by the way.
<?php $user = JFactory::getUser();
$usergroup=$user->getAuthorisedGroups();
if ($usergroup == '10') : ?>
<a href="<?php echo JURI::root(); ?>" id="gkLogo">
<img src="/images/fordlogo.png" alt="<?php echo $this->API->getPageName(); ?>" />
</a>
<?php elseif ($usergroup == '7') : ?>
<a href="<?php echo JURI::root(); ?>" id="gkLogo">
<img src="/images/tescologo.png" alt="<?php echo $this->API->getPageName(); ?>" />
</a>
<?php else; ?>
<a href="<?php echo JURI::root(); ?>" id="gkLogo">
<img src="<?php echo $logo_image; ?>" alt="<?php echo $this->API->getPageName(); ?>" />
</a>
<?php endif; ?>
Try something like this,
$user = JFactory::getUser();
$usergroup = $user->getAuthorisedGroups();
if(in_array('10',$usergroup)){
echo '<a href="'.JURI::root().'" id="gkLogo">
<img src="/images/fordlogo.png" alt="'.$this->API->getPageName().'" />
</a>';
}elseif(in_array('7',$usergroup)){
echo '<a href="'.JURI::root().'" id="gkLogo">
<img src="/images/fordlogo.png" alt="'.$this->API->getPageName().'" />
</a>';
}else{
echo '<a href="'.JURI::root().'" id="gkLogo">
<img src="/images/fordlogo.png" alt="'.$this->API->getPageName().'" />
</a>';
}
Hope this will help you.

Updating main product url on magento product page

I have a probelm with a magento project that I am currently building. My product page has a main image (configurable product) and thumbnails below. I have got my code to the stage where clicking a thumbnail appends the image to the main image area, however i require the href for the link it is contained it to also append to that imgs url. Hope this makes sense, any help welcome.
<?php
$_product = $this->getProduct();
$_helper = $this->helper('catalog/output');
?>
<div class="grid_12 grid_spacer_bottom">
<?php
$_img = '<img id="image" class="img-left img-inlineblock responsive-img" src="'.$this->helper('catalog/image')->init($_product, 'image').'" alt="'.$this->htmlEscape($this->getImageLabel()).'" />';
//echo $_helper->productAttribute($_product, $_img, 'image');
?>
<?php echo $_helper->productAttribute($_product, $_img, 'image'); ?>
</div>
<div class="clear"></div>
<?php if (count($this->getGalleryImages()) > 0): ?>
<div class="more-views">
<?php foreach ($this->getGalleryImages() as $_image): ?>
<div class="grid_4 grid_spacer_bottom">
<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" title="<?php echo $_product->getName();?>" onclick="$('image').src = this.href; return false;">
<img class="img-left img-inlineblock responsive-img" src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile()); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
</a>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
I'm assuming that you are try to make when you click on the large image it will have the url of the thumbnail
Give this href an ID
<?php echo $_helper->productAttribute($_product, $_img, 'image'); ?>
Are you using jquery or prototype (if default magento then this)
Prototype
$('img_href').setAttribute('href', this.href);
//$('img_href').href = this.href; // or
jQuery
$("#img_href").attr("href", this.href);
Plain Javascript
document.getElementById('img_href').href = this.href;
Update the thumbnail onclick
onclick="$('image').src = this.href; $('img_href').setAttribute('href', this.href); return false;"
$('image').parentNode.href='your url'; ?

Categories