Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

replace category title text with an image in magento 1.7

Posted on 2013-02-03
3
Medium Priority
?
805 Views
Last Modified: 2016-03-02
I have a store run by magento v1.7, it has a custom theme which works flawlessly apart from the fact that I can't get the title text to be replaced by an image.

If possible it would be great if an image could be displayed with the title text over the top for seo purposes.

I have tried several scripts and the image has been uploaded correctly to the media/catalog/category folder, also shows in the backend fine.

This is the script in the view.phtml;

<?php
    $_helper = $this->helper('catalog/output');
    $_category = $this->getCurrentCategory();
    $_imgHtml   = '';
    if ($_imgUrl = $_category->getImageUrl()) {
        $_imgHtml = '<p class="category-image"><img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" /></p>';
        $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
    }
?>


Any assistance would be greatly appreciated. I am new to magento so please explain clearly. Thanks.
0
Comment
Question by:Dan_Lapodo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 44

Accepted Solution

by:
Chris Stanyon earned 2000 total points
ID: 38850849
The code you've posted generates the HTML for the image and stores it in the $_imgHtml variable, but it doesn't output it anywhere. You need to make sure you're echoing that variable out wherever in your page you want the image to display. Something like this:

<?php if($_imgUrl): ?>
    <?php echo $_imgHtml ?>
<?php endif; ?>

Open in new window

0
 

Author Comment

by:Dan_Lapodo
ID: 38851067
Thanks for that ChrisStanyon, it works well and loads the image.

Is there any chance you know how to make the image responsive, the magento theme we have is responsive and when resized the image doesn't degrade?
0
 
LVL 44

Expert Comment

by:Chris Stanyon
ID: 38851207
There're several ways of using images in responsive design, but unfortunately no 'official' way of doing it. They all seem to have their own pros and cons - some rely on extra HTML markup, some just on CSS, and some use Javascript. One solution may be preferred over another but that will be down to your own personal choice / ability / restrictions etc.

I would advise Googling it (responsive design images). There's a lot of good articles out there which discuss the various methods, and you'll likely find one that suits your particular project.

Don't get too hung up on the fact that it's Magento - simply concentrate on the HTML, CSS etc.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Introduction to Processes
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question