Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Enabling simple BB codes in photo description  (Read 3485 times)

0 Members and 1 Guest are viewing this topic.

cgc0202

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 199
Enabling simple BB codes in photo description
« on: August 30, 2006, 10:24:06 pm »

Hi,

The caption for a photo is generally centered, and is the default format in the presentation of the title and addtional short captions (photographer name, address, etc.) of the photo in CPG. 

The default center alignment, is also the default alignment for long descriptions that may be included.  This is not always aesthetically good to look at.  Is it possible to specify, left align and right align and other combinations, also? 

Example 01:

"... That if all vicious men are bound together and constitute a force, then all honorable men ought to do the same ..."
-- Leo Tolstoy (War and Peace)

The description is "left aligned" while the attribution is "right aligned"

Example 02:

"...Oh Wind.
If Winter comes, can Spring be far behind?"

-- Ode to the West Wind
Percy Bysshe Shelley

In the second example given above, the first line, second line and attribution were "right aligned", "left aligned"  and "right aligned", respectively; before the entire text was boxed in a table and the table itself, centered -- to get the desired appearance of the quote from the poem.

Basically, I used the allowed simple BB tags in this forum, to enable the above formatting. I may have missed reading it in the Manual, but it would be nice if such basic simple BB tags are allowed in the photo description. 

Without the alignments, the default in the photo description would appear like these:

Example 1:

"... That if all vicious men are bound together and constitute a force, then all honorable men ought to do the same ..."
-- Leo Tolstoy (War and Peace)

Here, if the above quoted description is very long, and consists of multiple paragraphs, the appearance is not very nice.

Example 2:

"... Oh Wind.
If Winter comes, can Spring be far behind?"

-- Ode to the West Wind
Percy Bysshe Shelley

Again, the centered alignment is not the best presentation for poems. 


In the FAQ, there is an example to enable BB codes to allow clickable links:

******************
Edit displayimage.php and change
$info[$CONFIG['user_field'.$i.'_name']] = make_clickable($CURRENT_PIC_DATA['user'.$i]);
into
$info[$CONFIG['user_field'.$i.'_name']] = bb_decode($CURRENT_PIC_DATA['user'.$i]);
******************

How can all the other simple BB codes be allowed in the caption of the photo?

Thanks.

CGC

« Last Edit: September 01, 2006, 04:04:16 pm by cgc0202 »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Enabling simple BB codes in photo description
« Reply #1 on: August 31, 2006, 05:30:06 am »

The bbcode tags you can use in Coppermine differ from the bbcode tags in SMF. Coppermine only supports [ b ], [ i ], [ u r l ], [ e m a i l ], [ i m g ]. Adding in more bbcode tags is not that easy. I suggest looking up how phpBB (that's where Coppermine "borrowed" the bbcode processing from) handles additional bbcode tags.
Logged

Nibbler

  • Guest
Re: Enabling simple BB codes in photo description
« Reply #2 on: August 31, 2006, 01:09:31 pm »

You can add alignment tags fairly easily, just add this code into bb_decode() function in inlcude/functions.inc.php

Code: [Select]
         // [left] and [/left] for left align.
        $text = str_replace("[left]", '<div align="left">', $text);
        $text = str_replace("[/left]", '</div>', $text);
       
        // [center] and [/center] for centered.
        $text = str_replace("[center]", '<div align="center">', $text);
        $text = str_replace("[/center]", '</div>', $text);
       
        // [right] and [/right] for right align.
        $text = str_replace("[right]", '<div align="right">', $text);
        $text = str_replace("[/right]", '</div>', $text);

You may need code to balance the tags though.

[edit: typo]
« Last Edit: September 01, 2006, 04:17:37 pm by Nibbler »
Logged

cgc0202

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 199
Re: Enabling simple BB codes in photo description
« Reply #3 on: September 01, 2006, 04:00:51 pm »

Thanks Gau, Nibbler,

The added info is good to know.  Just to clarify:  Based from what you stated, provided it is a BB code, and I add it in the include/functions.inc.php, it will work?  Also, I will need them mostly in the "display"  presentation. In the FAQ, it had this note:

******************
Edit displayimage.php and change
$info[$CONFIG['user_field'.$i.'_name']] = make_clickable($CURRENT_PIC_DATA['user'.$i]);
into
$info[$CONFIG['user_field'.$i.'_name']] = bb_decode($CURRENT_PIC_DATA['user'.$i]);
******************

Is there a need to modify the displayimage.php, further?  Or, does the above edit enable the BB codes in the "display" page -- provided they have been included, as you stated, in the "include/functions.inc.php"?

I really do not expect to add more than alignments (not even img) and other formatting.  Aside from those you indicated in your responses, the only other one I need would be the "table" code.  I will look that up in the BB codes.  Thanks again.

CGC
« Last Edit: September 01, 2006, 04:17:03 pm by cgc0202 »
Logged

Nibbler

  • Guest
Re: Enabling simple BB codes in photo description
« Reply #4 on: September 01, 2006, 04:25:25 pm »

Once you change the bb_decode function they will work everywhere bbcode is allowed. Tables are difficult since you need to verify what the user is creating is a valid table. If it is not then it can break the layout of your page. If it's only you that will use the code then you should be ok.

Code: [Select]
        // [table] and [/table] for a table.
        $text = str_replace("[table]", '<table style="font: inherit; color: inherit;">', $text);
        $text = str_replace("[/table]", '</table>', $text);

        // [tr] and [/tr] for a table row.
        $text = str_replace("[tr]", '<tr>', $text);
        $text = str_replace("[/tr]", '</tr>', $text);
       
        // [td] and [/td] for a table cell.
        $text = str_replace("[td]", '<td valign="top" style="font: inherit; color: inherit;">', $text);
        $text = str_replace("[/td]", '</td>', $text);
Logged

cgc0202

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 199
Re: Enabling simple BB codes in photo description
« Reply #5 on: November 04, 2006, 06:48:32 pm »

Thanks Nibbler,

Yes, I hesitate to add the table tags.  Very risky.

Copying your examples as templates, I was able to add this and they work:

Code: [Select]
   // [sup] and [/sup] for superscript.
        $text = str_replace("[sup]", '<sup>', $text);
        $text = str_replace("[/sup]", '</sup>', $text);

   // [sub] and [/sub] for subscript.
        $text = str_replace("[sub]", '<sub>', $text);
        $text = str_replace("[/sub]", '</sub>', $text);

[Edit: Added code tags - Nibbler]
« Last Edit: November 04, 2006, 06:51:17 pm by Nibbler »
Logged

cgc0202

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 199
Re: Enabling simple BB codes in photo description
« Reply #6 on: November 04, 2006, 07:01:25 pm »

      Hi Nibbler,

      However, I had mixed success with these:

               //
[list=1] and [/ol] for ordered numerical listing.
        $text = str_replace("[list=1]", '<ol>', $text);
        $text = str_replace("[/list]", '</ol>', $text);


         // [list=a] and [/ol] for ordered alphabetical listing.
        $text = str_replace("[list=a]", '<ol>', $text);
        $text = str_replace("[/list]", '</ol>', $text);


         // [ul] and [/ul] for unordered enumeration.
        $text = str_replace("[ul]", '<ul>', $text);
        $text = str_replace("[/ul]", '</ul>', $text);

I tried to combine the above with either :

         //
  • and
for enumeration.
        $text = str_replace("
  • ", '<li>', $text);
            $text = str_replace("
", '</li>', $text);

or

         //
  • and [/*] for enumeration.
            $text = str_replace("
  • ", '<li>', $text);

        $text = str_replace("[/*]", '</li>', $text);


but they do not get the desired equivalent in the usual "html" pages.  I sometimes get "indention" and a "bullet" but not the numbered or alphabetized listing.

How are these  done properly?

Thanks.

Cornelio






Logged
Pages: [1]   Go Up
 

Page created in 0.058 seconds with 20 queries.