Author Topic: [Mod] Make the description of an image shorter and show it on the index.php  (Read 12721 times)

0 Members and 1 Guest are viewing this topic.

Offline CodeMan

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • ArabGlobe.com
Hello,

On the detail.html there is the (long) description of the images.
is it possible to make the description of an image shorter an show it on the index.php?
For example a description of 20 caracters instead of the whole description.

Thanks.
« Last Edit: April 20, 2013, 10:34:21 PM by CodeMan »

Rembrandt

  • Guest
Hi!

1.) search in includes/functions.php "?>" and insert above:

function word_count($string="",$length=0){ 
  
$shortened implode(' ',array_slice(str_word_count($string,1,'δόφΔάΦί,'),0,$length))." ..."
  return 
$shortened;
}


2.) search in index.php:

$new_images 
.= $site_template->parse_template("thumbnail_bit");

insert above:

$new_images 
.= $site_template->register_vars("image_description",word_count(format_text($image_row['image_description'],2),20));


3.) search in categories.php:

$thumbnails 
.= $site_template->parse_template("thumbnail_bit");

insert above:

$thumbnails 
.= $site_template->register_vars("image_description",word_count(format_text($image_row['image_description'],2),20));


4.) search in your Template/thumbnail_bit.html
Code: [Select]
<b>{image_name}</b> {if image_is_new}<sup class="new">{lang_new}</sup>{endif image_is_new} ({user_name_link})
insert below:
Code: [Select]
<br>
{image_description}

mfg Andi

Offline CodeMan

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • ArabGlobe.com
Rembrandt,

thanks for this great MOD, it works fine.

I tried to place {image_description} on the Random_image.html, but here the description was not shortened.

How can I use the SHORT {image_description} on the random_image.html or maybe on other pages like postcard, etc.?

Thanks!
« Last Edit: April 21, 2013, 09:28:30 PM by CodeMan »

Rembrandt

  • Guest
make it undo the changes in step 2.) and 3.)

1.) search in includes/functions.php:

$description 
= (!empty($image_row['image_description'])) ? format_text($image_row['image_description'], 101) : REPLACE_EMPTY;

and replace:

$description 
= (!empty($image_row['image_description'])) ? word_count(format_text($image_row['image_description'], 101),10) : REPLACE_EMPTY;


2.) search in details.php:

$site_template
->register_vars(array(
  
"msg" => $msg,

and replace:

$site_template
->register_vars(array(
"image_description" => (!empty($image_row['image_description'])) ? format_text($image_row['image_description'], 101) : REPLACE_EMPTY,
  
"msg" => $msg,


3.) search in your templates/random_image.html:
Code: [Select]
{if allow_comments}{lang_comments} {image_comments}{endif allow_comments}<br />{user_name}
insert below:
Code: [Select]
<br>
{image_description}

mfgAndi

Offline CodeMan

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • ArabGlobe.com
Rembrandt,

excellent work again!
The second variation of the MOD is also working fine!
Works fine for homepage, categoriepage and random_image (...not working for postcard_create, postcard_preview and other pages).
As I tried to explain in my previous post, it would be great to use a short image description on ANY page you like.

Allow me to ask you again...

My goal was to be able to place a short image description on any page I want (except detail.html).
Something similar as in the MOD http://www.4homepages.de/forum/index.php?topic=25981.0 where {cat_description_short} and {image_name_short} are used.

Hope you can understand that this MOD can be fantstic when the short image description can be placed on any page you like.

Thanks again!