Topic: Remove paragraph tags from images

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

Re: Remove paragraph tags from images

You mean this?

Re: Remove paragraph tags from images

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,

config.autoParagraph = false;

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

|--
Die deutsche GetSimple-Webseite: http://www.Get-Simple.de = the german Get-Simple-Website!
Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forum/forum/16/german-deutsch/

Re: Remove paragraph tags from images

Thanks for any help x

Re: Remove paragraph tags from images

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.

/* 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');

Re: Remove paragraph tags from images

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.

I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.

Re: Remove paragraph tags from images

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

Re: Remove paragraph tags from images

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

|--
Die deutsche GetSimple-Webseite: http://www.Get-Simple.de = the german Get-Simple-Website!
Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forum/forum/16/german-deutsch/

Re: Remove paragraph tags from images

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

Re: Remove paragraph tags from images

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

|--
Die deutsche GetSimple-Webseite: http://www.Get-Simple.de = the german Get-Simple-Website!
Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forum/forum/16/german-deutsch/

Re: Remove paragraph tags from images

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.

Post's attachments

paragraph_remover.zip 584 b, 11 downloads since 2012-01-26 

You don't have the permssions to download the attachments of this post.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.

Re: Remove paragraph tags from images

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!

Re: Remove paragraph tags from images

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