Jump to content

line break in image description field


biber
 Share

Recommended Posts

Hi,

is it possible to force a line break in an image description field?

I'm building a site with a gallery of cooking recipes. Each photograph shows one dish and in the description I write the ingredients and the preparation. But even if I use line breaks while filling the field, it comes without that.

Thanks in advance

Günter

Link to comment
Share on other sites

biber,

Here's an idea for you. I haven't tried this myself, so no guarantees:

  • Install the TextformatterNewlineBR module.
  • Go to your image field's settings and switch to the "Details" tab.
  • Scroll down and find the textformatters box.
  • Add "Newlines to XHTML Line Breaks" formatter to the image - and make sure it is listed after "HTML Entity Encoder" (if you have that setup on your field.)
  • View your page.

Hope that helps.

Steve

  • Like 4
Link to comment
Share on other sites

Edit: Netcarvers solution is the recommended one. But here an approach from the API side:
I think the only way is to use a Textformatter like Markdown or in your case TextformatterNewlineBR.


 

If you want to format your description inside the template use a Textformatter like Markdown or in your case TextformatterNewlineBR.
Your description : 'Description with \n Line break'
should output: 'Description with <br/> Line break'

in your Template:

$desc = $page->image->description;
$desc = $modules->get('TextformatterNewlineBR')->format($desc);

You maybe have to set $page->of(false) before grabbing $desc. Just try out.

@netcarver
You where quicker and better ;) I didn't know this ...

Edited by kixe
  • Like 3
Link to comment
Share on other sites

biber,

Here's an idea for you. I haven't tried this myself, so no guarantees:

  • Install the TextformatterNewlineBR module.
  • Go to your image field's settings and switch to the "Details" tab.
  • Scroll down and find the textformatters box.
  • Add "Newlines to XHTML Line Breaks" formatter to the image - and make sure it is listed after "HTML Entity Encoder" (if you have that setup on your field.)
  • View your page.

Hope that helps.

Steve

Thanks for your help. I didn't find a module "TextformatterNewlineBR" but one called "TextformatterAutoParagraph", which seemed to comply with my request. As you described I installed it and added it to the textformatters box, but above the "HTML Entity Encoder" and --Yippee!-- all texts are formattet properly.

@ Kixe:

Thanks for your suggestion. But the simple way netcarver showed me just fixed my problem, so I did not try to find another solution.

Great CMS - Great forum

Günter

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...