GetSimple Support Forum
Remove paragraph tags from images - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16)
+--- Thread: Remove paragraph tags from images (/showthread.php?tid=2637)



Remove paragraph tags from images - kate - 2012-01-21

Hi

Can anyone help with how to define GSEDITOROPTIONS to remove <p> tags from images that are inserted into a page? I've searched everywhere in the forum/wiki and can't find an answer to this.

Many thanks

Kate


Remove paragraph tags from images - Ampersand - 2012-01-21

You mean this?


Remove paragraph tags from images - Connie - 2012-01-21

no, absolutely not. You pointed to the definition of the tag which shall be embedded when doing a line-break in the editor.

Kate wants to integrate images whithout enclosing <p>-tags around the <img>-tag

I checked and thought I found a solution,

Code:
config.autoParagraph = false;

but this did not work. I will try to find a solution.


Remove paragraph tags from images - kate - 2012-01-21

Thanks for any help x


Remove paragraph tags from images - kate - 2012-01-23

I managed to use a function borrowed from wordpress to remove p tags on the images. It doesn't solve the editor problem as such though - e.g if an image is floated and the text sits beside it in the editor it still wraps the image and text in a paragraph. Still looking for a better solution for the editor options.

Code:
/* Remove ptags from images */
function filter_ptags_on_images($content){
    return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}

add_filter('content', 'filter_ptags_on_images');



Remove paragraph tags from images - mvlcek - 2012-01-23

kate Wrote:I managed to use a function borrowed from wordpress to remove p tags on the images. It doesn't solve the editor problem as such though - e.g if an image is floated and the text sits beside it in the editor it still wraps the image and text in a paragraph. Still looking for a better solution for the editor options.

WHY do you want to remove the paragraph around the image?
I have setup the editor with custom styles, so e.g. if I want to float the image right, I just assign the class 'rfloat' to the paragraph and the image floats to the right.


Remove paragraph tags from images - kate - 2012-01-24

It's a CSS issue really - if the img is wrapped in <p> tags and I want to do something with the other paragraphs, it affects the image as well.

This situation isn't a problem with html pages I'm designing for myself, it's more to do with keeping the editor as simple as possible for clients. Normally I'd just use another div or assign a class to sort out the styling, but I've already started testing the cms on a non-savvy client who messed a really simple page.

It's all a learning experience and in the main Get Simple is doing a great job so thanks!

Kate


Remove paragraph tags from images - Connie - 2012-01-24

well, Kate, I couldn't find a solution for your question, maybe due to my flu,

but I must say that this behaviour is not a GS behaviour, it is a feature of CKEditor (no, I do not want to blame this editor, which is my favorite editor!, other editor have more or other problems, weaknesses etc.)

It is like it is. If you do not want to get the "normal" paragraph layout when an image is added, maybe you can style it with CSS (something like "paragraphs which have image inside : display:inline" or so...)

cheers, Connie


Remove paragraph tags from images - kate - 2012-01-27

Connie, thanks for trying. Sorry to hear you've not been well, hope you're feeling better now.

N.b. the filter I posted earlier didn't work on the live site (ok in the local server).

Don't get me wrong, I like the editor so I'm figuring out the best way to set things up for the future and to keep problems to a minimum.

Kate


Remove paragraph tags from images - Connie - 2012-01-27

Kate,

thanks! I am still "restricted" by the flu.... but slowly getting better

well, I could not find a solution. If I remember well, there must be configuration not to add <p> at all, not only with images, but with other objects, too
but I can't figure out which setting this is

I also try to find out how to omitt the _cke_editor_saved_attribute which is added to image links in the last versions... and why it is added ;=(

when I am stronger, maybe I will get my memory back ;=)

Cheers, Connie


Remove paragraph tags from images - mvlcek - 2012-01-27

kate Wrote:N.b. the filter I posted earlier didn't work on the live site (ok in the local server).

Your regular expression has some issues, if there are multiple images or links or images without links.
Try the attached plugin.


Remove paragraph tags from images - kate - 2012-01-27

mvlcek Wrote:
kate Wrote:N.b. the filter I posted earlier didn't work on the live site (ok in the local server).

Your regular expression has some issues, if there are multiple images or links or images without links.
Try the attached plugin.


Thank you the plugin is great so far!


Remove paragraph tags from images - WAXMASSIVE - 2012-02-20

Works great as Drupal input filter to tame the autocorrecting madness of ckeditor too. ;D
Big thankyous are well deserved!


RE: Remove paragraph tags from images - Timbow - 2014-02-08

2yrs on and I am trying to remove p tags from images as well. Was there ever a solution to this? there is an 'attached plugin' from mvlcek which is no longer there. Is it still available mvlcek?.

I am working on a layout where the images have no side margins but the text does.


RE: Remove paragraph tags from images - Carlos - 2014-02-08

(2014-02-08, 22:25:16)Timbow Wrote: there is an 'attached plugin' from mvlcek which is no longer there. Is it still available mvlcek?.

You can download it from Oleg06's site:
http://getsimplecms.ru/plaginy-dlya-getsimple-cms/plagin-premover/


RE: Remove paragraph tags from images - Timbow - 2014-02-08

Got it.

Thanks Carlos, Oleg, Martin