Author Topic: How to pull image description in template?  (Read 5488 times)

Offline cookie

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +10/-0
    • View Profile
How to pull image description in template?
« on: January 24, 2014, 06:18:04 PM »
Hi,
I noticed that images have a field called "description" attached to them, but that information is not used anywhere!

How can I pull the description in php to include it in a template?
(and by the occasion, maybe the image title as well)

Thanks!

gordontaylor

  • Guest
Re: How to pull image description in template?
« Reply #1 on: January 24, 2014, 07:53:36 PM »
Cookie the images are in this path:

storefront>view>default_html5>image

The description is probably an "alt" message you can if the image doesn't render for some reason. Also an excellent SEO technique, using "alt" tags on images. Every image should have one. However, you'll need to add the "alt" tag to the image in the HTML.

Gordon

Offline cookie

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +10/-0
    • View Profile
Re: How to pull image description in template?
« Reply #2 on: January 25, 2014, 06:10:22 PM »
Hi,

Well actually I am looking for the php bit to get that image description.
I tried
Code: [Select]
<?php echo $image['description']; ?> but it does nothing.
The info is saved in the database but something is not properly defined somewhere.

Nope, that bit is not used as "alt", just the name is used everyhwere and for everything. Wonder why ?!?

This is the code from product.tpl
Code: [Select]
<img src="<?php echo $image_url?>" alt="<?php echo $image['title']; ?>" title="<?php echo $image['title']; ?>">
I'd like to display that description bellow the image, there is not that much info on the page anyways.

Do you have an idea how to get that working?

Thx

gordontaylor

  • Guest
Re: How to pull image description in template?
« Reply #3 on: January 25, 2014, 08:07:50 PM »
Hi,

Well actually I am looking for the php bit to get that image description.
I tried
Code: [Select]
<?php echo $image['description']; ?> but it does nothing.
The info is saved in the database but something is not properly defined somewhere.

Nope, that bit is not used as "alt", just the name is used everyhwere and for everything. Wonder why ?!?

This is the code from product.tpl
Code: [Select]
<img src="<?php echo $image_url?>" alt="<?php echo $image['title']; ?>" title="<?php echo $image['title']; ?>">
I'd like to display that description bellow the image, there is not that much info on the page anyways.

Do you have an idea how to get that working?

Thx

OK, as you can see, those calls are simply calling an image, with the "alt" text, in this case the "alt" text is the title and also the third call is calling the title. They are NOT calling any description. You'll have to add the description in HTML under that line of code, assuming your description isn't too long. It would require you to rewrite every product page, not an easy task. Alternately, you can write a the php to call that info, but I'm not sure if you have that skill set.

There is ample room on the Insert product page for a description of the item you're selling. The "alt" title will show before the image loads, the title is under the image. A great example is the dashboard when you log into your Amin panel.

The description that is displayed with the product is in a different block of php. Look at this product page on my website http://wholesaleostomysupplies.com/index.php?rt=product/product&path=65_74&product_id=113 and you'll see the description below the add to cart button. Is that not sufficient for your needs?

If you want to add the description right under your product image, you'll need to re-write that entire piece of php that displays the image, and that will be a real chore, As you can see in my example, I add as much descriptive info as I can in the product name box when building the product page.

I think I have covered what you want to know, I'm not entirely sure exactly what or where you want the description.

Alternately, you can use an image editor and add the text to the image, if it's not that much text.

Offline cookie

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +10/-0
    • View Profile
Re: How to pull image description in template?
« Reply #4 on: January 25, 2014, 08:20:17 PM »
well, the thing is I want to display products with a bunch of images and options, each image and each option earning their very own description.

So I thought I could make use of that image description to achieve that and yes, that would require to edit the product.tpl
But it's obvious that the parameter "image [description]" was lost somewhere along the way and it does not work.

I managed to pull the title with
Code: [Select]
<?php echo $image['title']; ?> but when I try
Code: [Select]
<?php echo $image['description']; ?> that brings out nothing!!

I also did not get it working for the options images, that seems to be an other story
I do not seem to find any of the info I need  >:(

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2048
  • Karma: +319/-13
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: How to pull image description in template?
« Reply #5 on: January 27, 2014, 02:26:22 PM »
try to replace file public_html/core/engine/resources.php (i added image description) see attachment
and then try to use echo $image['description'] in your tpl
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline cookie

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +10/-0
    • View Profile
Re: How to pull image description in template?
« Reply #6 on: January 27, 2014, 07:52:06 PM »
Hi,
Thank you v.much for the file! I replaced it and than tried to use the following in product.tpl

Code: [Select]
<div class="custom_img_name"><?php echo $image['title']; ?></div>
<div class="custom_img_desc"><?php echo $image['description']; ?></div>

echo $image['title'];  works, echo $image['description'];  not  :-[

I checked the image does have a description defined in the library ....

Any ideas what am I doing wrong?

Thx

 

Powered by SMFPacks Social Login Mod