4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: CodeMan on April 20, 2013, 01:29:53 AM

Title: [Mod] Make the description of an image shorter and show it on the index.php
Post by: CodeMan on April 20, 2013, 01:29:53 AM
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.
Title: Re: [Mod] Make the description of an image shorter and show it on the index.php
Post by: Rembrandt on April 21, 2013, 05:14:47 PM
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
Title: Re: [Mod] Make the description of an image shorter and show it on the index.php
Post by: CodeMan on April 21, 2013, 08:49:08 PM
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!
Title: Re: [Mod] Make the description of an image shorter and show it on the index.php
Post by: Rembrandt on April 22, 2013, 07:49:52 AM
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'], 1, 0, 1) : REPLACE_EMPTY;

and replace:

$description = (!empty($image_row['image_description'])) ? word_count(format_text($image_row['image_description'], 1, 0, 1),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'], 1, 0, 1) : 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
Title: Re: [Mod] Make the description of an image shorter and show it on the index.php
Post by: CodeMan on April 22, 2013, 08:36:32 PM
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 (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!