Author Topic: Description text default  (Read 4979 times)

0 Members and 1 Guest are viewing this topic.

Offline edonai

  • Newbie
  • *
  • Posts: 32
    • View Profile
Description text default
« 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.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Description text default
« Reply #1 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;
« Last Edit: August 26, 2009, 02:34:14 PM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline edonai

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Description text default
« Reply #2 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 !

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Description text default
« Reply #3 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.
« Last Edit: August 26, 2009, 02:34:57 PM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Hagen-Roderich

  • Full Member
  • ***
  • Posts: 127
    • View Profile
    • Hof Jokers
Re: Description text default
« Reply #4 on: August 26, 2009, 09:20:03 AM »
How to get the "cat_name" as description?

Thanks

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Description text default
« Reply #5 on: August 26, 2009, 02:33:53 PM »
  $image_description = ($image_description === "") ? addslashes($cat_cache[$cat_id]['cat_name']) : $image_description;
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)