Posts: 23
Threads: 5
Joined: Jan 2012
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
Posts: 88
Threads: 9
Joined: Feb 2011
Posts: 2,928
Threads: 195
Joined: Feb 2011
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.
Posts: 23
Threads: 5
Joined: Jan 2012
Posts: 23
Threads: 5
Joined: Jan 2012
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');
Posts: 2,094
Threads: 54
Joined: Jan 2011
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.
Posts: 23
Threads: 5
Joined: Jan 2012
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
Posts: 2,928
Threads: 195
Joined: Feb 2011
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
Posts: 23
Threads: 5
Joined: Jan 2012
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
Posts: 2,928
Threads: 195
Joined: Feb 2011
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
Posts: 2,094
Threads: 54
Joined: Jan 2011
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.
Posts: 23
Threads: 5
Joined: Jan 2012
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!
Posts: 1
Threads: 0
Joined: Feb 2012
Works great as Drupal input filter to tame the autocorrecting madness of ckeditor too. ;D
Big thankyous are well deserved!
Posts: 1,127
Threads: 136
Joined: Feb 2012
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.
Posts: 3,491
Threads: 106
Joined: Mar 2010
(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/
Posts: 1,127
Threads: 136
Joined: Feb 2012
Got it.
Thanks Carlos, Oleg, Martin
|