Page 2 of 3
Re: Adding custom alt text to product images
Posted: Mon Feb 18, 2013 3:46 am
by cosmo
U need to alter the database request in the model-file (catalog/model/product )
I know I currently have an error in mine so I won't share it until it's fixed.
Re: Adding custom alt text to product images
Posted: Mon Feb 18, 2013 3:59 am
by Lundii30
Cosmo, thank you for your reply. Please let me know if you have any luck with the model-file.
Re: Adding custom alt text to product images
Posted: Tue Feb 19, 2013 12:21 am
by cosmo
Fixed the model and control for the product page presentation.
Product page template file needs to be edited something like (example based on default schema):
Code: Select all
<?php if ($thumb || $images) { ?>
<div class="left">
<?php if ($thumb) { ?>
<div class="image"><a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" class="colorbox" rel="colorbox"><img src="<?php echo $thumb; ?>" title="<?php echo $image_title_text; ?>" alt="<?php echo $image_alt_text; ?>" id="image" /></a></div>
<?php } ?>
<?php if ($images) { ?>
<div class="image-additional">
<?php foreach ($images as $image) { ?>
<a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>" class="colorbox" rel="colorbox"><img src="<?php echo $image['thumb']; ?>" title="<?php echo $image['image_title_text']; ?>" alt="<?php echo $image['image_alt_text']; ?>" /></a>
<?php } ?>
</div>
<?php } ?>
</div>
<?php } ?>
More work is coming to deploy texts to category listings page, search results page and so on...
File deleted
Re: Adding custom alt text to product images
Posted: Tue Feb 19, 2013 3:24 am
by Lundii30
Wow thanks a lot Cosmo, I will definitely give it a try!
Appreciate your help!
Re: Adding custom alt text to product images
Posted: Tue Feb 19, 2013 9:26 am
by Lundii30
It doesn't really seem to work for me..
what do I put in the catalog/controller/product/product.php?
I had this:
Code: Select all
foreach ($results as $result) {
$this->data['images'][] = array(
'popup' => $this->model_tool_image->resize($result['image'].........,
'thumb' => $this->model_tool_image->resize($result['image']........,
'alt_text' => $result['alt_text'],
'title_text' => $result['title_text']
);
}
And I also tried changing them to 'image_alt_text' and 'image_title_text', but it gives me the error
undefined variable... either way.
Re: Adding custom alt text to product images
Posted: Tue Feb 19, 2013 3:17 pm
by cosmo
That's because it needs to get the image text out of the image array..
Code: Select all
foreach ($results as $result) {
$this->data['images'][] = array(
'popup' => $this->model_tool_image->resize($result['image'].........,
'thumb' => $this->model_tool_image->resize($result['image']........,
'alt_text' => $result['image']['image_alt_text'],
'title_text' => $result['image']['image_title_text']
);
}
Re: Adding custom alt text to product images
Posted: Tue Feb 19, 2013 10:13 pm
by Lundii30
AWESOME! That worked! Thank you so much.
I do have one problem still (had this problem since I uploaded the 5 xml files).. all of my product links on the category pages don't work. When I look at the URL in the address bar it leaves the product id blank like this:
/index.php?route=product/product&path=59&product_id=
and then opens a page that says:
Product not found!
Do you know what I can do about that??
Again, thank you so much for taking the time to get back to me. I really appreciate your help!
Re: Adding custom alt text to product images
Posted: Wed Feb 20, 2013 1:57 am
by cosmo
Yes, I got another comment about that.
The error is confirmed and I will have a look at it as soon as I get a chance.
Re: Adding custom alt text to product images
Posted: Wed Feb 20, 2013 3:31 am
by Lundii30
Thank you for looking into it.
Re: Adding custom alt text to product images
Posted: Wed Feb 20, 2013 7:31 am
by Lundii30
...forgot to mention.. the "add to cart" buttons don't work either on the catalog pages..
Re: Adding custom alt text to product images
Posted: Wed Feb 20, 2013 11:49 pm
by cosmo
Found the issue, ambigous column names in the image text table and the product table. Both are named 'product_id'.
I will write a migration script for the db-table and update the vqmod-xmls accordingly.
So, today I learned to always specifically prefix your custom database tables!
Re: Adding custom alt text to product images
Posted: Thu Feb 21, 2013 12:14 am
by cosmo
Ok, new version.
If previous version installled:
1. Replace all old xmls.
2. Run the migrate_product_image_text.sql (simply renames the product_id column in the custom table).
Keep posting any issues.
Re: Adding custom alt text to product images
Posted: Thu Feb 21, 2013 12:53 am
by Lundii30
PERFECT!!! Everthing works now..
when I ran the migrate_product_image_text.sql is gave me the following:
MySQL returned an empty result set (i.e. zero rows). (Query took 0.0072 sec)
But everything seems to be alright.
THANK you so much.
Re: Adding custom alt text to product images
Posted: Thu Feb 21, 2013 11:45 pm
by cosmo
Aaaaand another version where I've added custom alt and title text to all product presentations
- category page
- search page
- manufaturer page
- compare page
- bestseller module
- featured module
- latest module
- special module
All templates needs to be updated accordingly to display the texts.
If previously installed just replace the image_alt_and_title_text_catalog_controller.xml with the one in this package.
Re: Adding custom alt text to product images
Posted: Thu Apr 18, 2013 2:58 am
by timparnell
Wow, you have just saved me an age of work.
I have created a similar system so you can customise the product and category Page Titles.
My customer asked for this as apparently this is good for SEO...
If anyone is interested I can pull it together as a mod and contribute it.
Tim
Re: Adding custom alt text to product images
Posted: Thu Apr 25, 2013 11:08 pm
by josephchauhan
Can you make it work with 1.5.5.1..... I tried to install but it dosen't work.....
i get this error #1054 - Unknown column 'product_id' in 'product_image_text' when i rum Migrate product image text and the store stops responding...... but then i later figured out that i need to rename Proudct_image_text to oc_product_image_text....
Re: Adding custom alt text to product images
Posted: Mon Jun 17, 2013 5:00 pm
by newtress
This seems to work like a charm using a highly customized theme on OC version 1.5.5.1 so long as you follow the directions and make sure to make the necessary changes to the Product Template and Product Controller File, as well as the database, including the prefix.
One thing we had to make sure of was that the Alt Tags correspond with the correct pictures in your store, as they may display on the wrong images depending on which you consider the main and which is the additional image. Our theme has a hover effect that changes the popup image, so we have to make sure that the popup image is always considered the main image in the product template file and adjust the alt to reflect that.
While I must commend @Cosmos and all the others on their effort, I have one silly question. If you check out this page of our Developmental Site
http://dev.newtress.com/index.php?route ... duct_id=42 site, you will realize that the products all have closing brackets after them. This doesn't appear on other products on the site that do not have Alt Text. Why does this appear now?
Best,
NewTress
Re: Adding custom alt text to product images
Posted: Mon Jun 17, 2013 6:43 pm
by cosmo
Looks like the template is malformed.
Make sure the img-tag is closed correctly and not before the alt-text-check.
Re: Adding custom alt text to product images
Posted: Tue Jun 18, 2013 11:45 am
by newtress
Hey Cosmos,
Turns out it was a spacing issue. When I copied the code the closing tag for the image was too close to the closing tags for the image_alt_text output, so by adding that extra space it fixed everything. Otherwise, great plugin and we will be implementing it on our main hair extensions site
http://www.newtress.com today.
Amazing work to this point Cosmos. Why not just bundle the package into an extension on the OpenCart Extensions or do you prefer the intimacy and close knit nature of the forum?
Re: Adding custom alt text to product images
Posted: Sat Jul 20, 2013 2:48 pm
by neilrogero
How to Add custom alt text to product image?