4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: edonai on August 23, 2009, 08:03:13 PM

Title: Description text default
Post by: edonai on August 23, 2009, 08:03:13 PM
Hello the community,

I did a search on the forum but apart from how to hide or make the description field obligatory, I did not answer my question.

   
I want a default text is displayed if the user who upload the image does not enter a description.
Title: Re: Description text default
Post by: V@no on August 24, 2009, 03:34:06 AM
Quiet simple. In member.php find:
$image_description = un_htmlspecialchars(trim($HTTP_POST_VARS['image_description']));
(there are two instances of this line, first is used when image being uploaded and second when a user save image info after edit)

Insert below:
  $image_description = ($image_description === "") ? addslashes("Your text here") : $image_description;
Title: Re: Description text default
Post by: edonai on August 24, 2009, 10:38:51 PM
thanks but i've an error :

Code: [Select]
DB Error: Bad SQL Query: INSERT INTO 4images_images (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments) VALUES (1, 1, 'test3', 'Aucune description donnée par l'uploader', '', 1251146250, 1, 'AnimePaperwallpapers_Hiiro-no-Kakera_Yina1.6_1280x800_82202.jpg', 'AnimePaperwallpapers_Hiiro-no-Kakera_Yina1.6_1280x800_82202.jpg', '', 1)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'uploader', '', 1251146250, 1, 'AnimePaperwallpapers_Hiiro-no-Kakera_Yina1.6_1280' at line 4

i put your code in the two instances, it's right??


EDIT :    
sorry, mistake on my part: I put accents in my text. It's works

Thanks V@no, you're great !
Title: Re: Description text default
Post by: V@no on August 25, 2009, 02:50:16 AM
if you need to use apostrophes ( ' ), then you must escape them with a back slash: \'
I've updated the code above to automatically add slashes.
Title: Re: Description text default
Post by: Hagen-Roderich on August 26, 2009, 09:20:03 AM
How to get the "cat_name" as description?

Thanks
Title: Re: Description text default
Post by: V@no on August 26, 2009, 02:33:53 PM
  $image_description = ($image_description === "") ? addslashes($cat_cache[$cat_id]['cat_name']) : $image_description;