biber Posted April 14, 2016 Share Posted April 14, 2016 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 More sharing options...
netcarver Posted April 14, 2016 Share Posted April 14, 2016 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 4 Link to comment Share on other sites More sharing options...
kixe Posted April 14, 2016 Share Posted April 14, 2016 (edited) 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.@netcarverYou where quicker and better I didn't know this ... Edited April 14, 2016 by kixe 3 Link to comment Share on other sites More sharing options...
tpr Posted April 14, 2016 Share Posted April 14, 2016 Just thinking out loud... a TextformatterNewCar could come handy 1 Link to comment Share on other sites More sharing options...
biber Posted April 14, 2016 Author Share Posted April 14, 2016 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 More sharing options...
netcarver Posted April 14, 2016 Share Posted April 14, 2016 Just thinking out loud... a TextformatterNewCar could come handy Nice try, tpr! 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now