4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: ruudvroon on October 28, 2005, 08:04:07 PM

Title: [MOD] Add keywords / description in image alt tag
Post by: ruudvroon on October 28, 2005, 08:04:07 PM
How can I add the keywords (without links) to the alt description?
I tried to add  {image_keywords} to the media template, but I get random keywords  :?
Title: Re: [Req]Add keywords in image alt
Post by: lemccoy on October 31, 2005, 11:43:03 PM
Has anyone figured out how to do this? I see the image keywords is coming from the random image in the page.  How do you get the main image to have it's main keywords?
Thanks
Title: Re: [Req]Add keywords in image alt
Post by: ruudvroon on November 02, 2005, 12:49:22 PM
Please someone, I need it because i want google image search can find the images.
Title: Re: [Req]Add keywords in image alt
Post by: ruudvroon on November 02, 2005, 02:00:45 PM
I made a sollution:

Open includes/functions.php

Find:
Code: [Select]
  else {
    $user_name = $lang['userlevel_guest'];
    $user_name_link = $user_name;
  }

Add below:
Code: [Select]
if ($detailed_view) {
  if (!empty($image_row['image_keywords'])) {
    $split_keywords2 = explode(" ", $image_row['image_keywords']);
    $keywords2 = "";
    foreach ($split_keywords2 as $key2 => $val2) {
      $keywords2 .= (($keywords2 != "" ) ? ", " : "")."$val2";
    }
}



   $site_template->register_vars(array(
     "alt_keywords" => $keywords2,
   ));
 }

Open templates/{your_template}/media/jpg.html

Find:
Code: [Select]
alt="{image_name}"

Replace with:
Code: [Select]
alt="{image_name}, {alt_keywords}"

Is there someone who can add the , in the {alt_keywords} because you now you also get a , when there're no keywords?
Title: Re: [Req]Add keywords in image alt
Post by: V@no on November 02, 2005, 02:20:45 PM
Code: [Select]
alt="{image_name}{if alt_keywords}, {alt_keywords}{endif alt_keywords}"
Title: Re: [Req]Add keywords in image alt
Post by: lemccoy on November 02, 2005, 03:40:31 PM
Perfect.  Thanks a bunch guys.
Title: Re: [Req]Add keywords in image alt
Post by: edwin on November 03, 2005, 12:59:25 AM
mayby an stupid question, but what if i want to show the image description ?
Title: Re: [Req]Add keywords in image alt
Post by: ruudvroon on November 03, 2005, 07:54:40 AM
Open includes/functions.php

Find:
Code: [Select]
  else {
    $user_name = $lang['userlevel_guest'];
    $user_name_link = $user_name;
  }

Add below:
Code: [Select]
if ($detailed_view) {
$description2 = (!empty($image_row['image_description'])) ? format_text($image_row['image_description'], 1) : REPLACE_EMPTY;
  if (!empty($image_row['image_keywords'])) {
    $split_keywords2 = explode(" ", $image_row['image_keywords']);
    $keywords2 = "";
    foreach ($split_keywords2 as $key2 => $val2) {
      $keywords2 .= (($keywords2 != "" ) ? ", " : "")."$val2";
    }
}
   $site_template->register_vars(array(
     "alt_keywords" => $keywords2,
     "alt_description" => $description2,
   ));
 }

Open templates/{your_template}/media/jpg.html

Find:
Code: [Select]
alt="{image_name}"

Replace with:
Code: [Select]
alt="{image_name}{if alt_description}, {alt_description}{endif alt_description}"
Title: Re: [Req]Add keywords in image alt
Post by: edwin on November 03, 2005, 04:06:18 PM
Great this is the right way,

it works in detailview, but is it also possible in the categoriesview and on the indexpage
Title: Re: [Req]Add keywords in image alt
Post by: bibabobu on November 03, 2005, 05:13:54 PM
Yeah thats all great.

Is it possible to have the image description AND the keywords :?:

That would be absolut fantastic  :mrgreen:
Title: Re: [Req]Add keywords in image alt
Post by: ruudvroon on November 03, 2005, 06:37:10 PM
just use the code from the description:

Open templates/{your_template}/media/jpg.html

Find:
Code: [Select]
alt="{image_name}{if alt_description}, {alt_description}{endif alt_description}"
Replace with:
Code: [Select]
alt="{image_name}{if alt_keywords}, {alt_keywords}{endif alt_keywords}{if alt_description}, {alt_description}{endif alt_description}"
Or:
Code: [Select]
alt="{image_name}{if alt_description}, {alt_description}{endif alt_description}{if alt_keywords}, {alt_keywords}{endif alt_keywords}"
Title: Re: [Req]Add keywords in image alt
Post by: edwin on November 04, 2005, 02:32:34 AM
Ruud, can you please take a look how i can place it in index page and the categoriespage

thanks in advance
Title: Re: [Req]Add keywords in image alt
Post by: bibabobu on November 04, 2005, 01:00:01 PM
Thanks ruudvroon :D

Great MOD i think.

It is working perfect for me.

Just one thing, which could irritate the beginners.
You forgot the alt="" tag in front of the code which must be replaced.

Code: [Select]
alt="{image_name}{if alt_description}, {alt_description}{endif alt_description}{if alt_keywords}, {alt_keywords}{endif alt_keywords}" :mrgreen:
Title: Re: [Req]Add keywords in image alt
Post by: V@no on November 04, 2005, 02:42:45 PM
little correction
these lines:
Code: [Select]
     "alt_keywords" => $keywords2,
     "alt_description" => $description2,
should be like this:
Code: [Select]
     "alt_keywords" => str_replace("\"", """, $keywords2),
     "alt_description" => str_replace("\"", """, $description2),

to avoid conflict if a description or a keyword contain a quote
Title: Re: [Req]Add keywords in image alt
Post by: edwin on November 04, 2005, 04:48:16 PM
V@no, master of 4images, can you tell me what and wich pages i have to change if i want to show the description also on the indexpage(home) and the categoriespage and not only the detailview
Title: Re: [Req]Add keywords in image alt
Post by: bibabobu on March 05, 2007, 12:23:25 AM
Hello!

On my 4images galerie version 1.7.1 it was working perfectly.

Now i have updated on version 1.7.4 and it is NOT working anymore.

I would also like to have this for SEO reasons under version 1.7.4

Thanks for support on this old but good topic.
Title: Re: [Req]Add keywords in image alt
Post by: hinzwiekunz on December 29, 2007, 02:34:41 PM
Hi,
i also want to use this MOD for SEO-optimizing.
Perhaps {alt_keywords} couldnt be used in the metatags in this way?