Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove paragraph tags from images
#1
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
Reply
#2
You mean this?
Reply
#3
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.
|--

Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#4
Thanks for any help x
Reply
#5
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');
Reply
#6
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.
Reply
#7
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
Reply
#8
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
|--

Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#9
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
Reply
#10
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
|--

Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#11
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.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#12
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!
Reply
#13
Works great as Drupal input filter to tame the autocorrecting madness of ckeditor too. ;D
Big thankyous are well deserved!
Reply
#14
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.
Reply
#15
(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-gets...-premover/
Reply
#16
Got it.

Thanks Carlos, Oleg, Martin
Reply




Users browsing this thread: 2 Guest(s)