Jump to content


Photo

HTML in File/Image descriptions


  • Please log in to reply
2 replies to this topic

#1 interrobang

interrobang

    Distinguished Member

  • Members
  • PipPipPipPip
  • 108 posts
  • 50

  • LocationMunich, Germany

Posted 19 June 2012 - 07:38 AM

I need to use some simple html-tags like <b> in file descriptions but they get stripped after save. Is there some option to allow html in file/image descriptions?

In my case its sufficient to enter the html-tags by hand, but would it be possible to use tinymce for editing the description?

I know I can use repeaters as an alternative, I just love the multi-file upload of the file-fieldtype so much..

#2 ryan

ryan

    Hero Member

  • Administrators
  • 5,780 posts
  • 3124

  • LocationAtlanta, GA

Posted 19 June 2012 - 11:37 AM

I recommend using either Textile or Markdown if you need to support this type of stuff in your image/file descriptions. For instance, in Markdown you would make bold text **like this**

You'll need to run your image/file descriptions through Textile or Markdown before outputting them. So can do that like this. I'll use Markdown in this example since the module is already in the core.

$markdown = $modules->get('TextformatterMarkdownExtra');
$description = $page->image->description; // your image description
$markdown->format($description); 
echo "<p><img src='{$page->image->url}' alt='' /> $description</p>";

We'll likely add internal support for these Textformatters for image/file descriptions in the near future, so that you don't have to do the above if you don't want to.

#3 interrobang

interrobang

    Distinguished Member

  • Members
  • PipPipPipPip
  • 108 posts
  • 50

  • LocationMunich, Germany

Posted 19 June 2012 - 11:43 AM

Thank you Ryan,
your idea works perfectly fine in my use case. This is even better then entering tags! I always forget these Textformatters exist.

Nice to hear they will get internal support!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users