Page 1 of 1

Back Ground Image

Posted: Thu Jun 10, 2021 7:34 pm
by Barrowboy
Hi
Can anyone explain how I can show an image in the background of the page but not in admin when editing.

My CSS at the moment is:

body {
background-image:url(https://www.mysite/uploads/images/body-bg.jpg);
background-repeat:repeat;
}

The problem is the image shows when editing a page which makes it difficult to add text etc. I would like to remove it from admin.

Thanks

Re: Back Ground Image

Posted: Thu Jun 10, 2021 11:27 pm
by paulbaker
One way: If you use TinyMCE (find out at My Preferences > My Account > User Preferences > Select WYSIWYG to use).

Then: Extensions > TinyMCE WYSIWYG editor and have a look around there (can't find an installation with TinyMCE at the moment to give you further details). Pretty sure there is an option to add specific CSS.

Re: Back Ground Image

Posted: Fri Jun 11, 2021 6:41 am
by Barrowboy
Hi
Yes there is an option to add CSS in Tinymce which we are already using, but these only affect the content page you are edit at the time.


I am trying to remove/hide a background image from Tinymce admin which shows in the editor while editing a page which prevents from seeing the text.

Thanks

Re: Back Ground Image

Posted: Sat Jun 12, 2021 1:49 pm
by velden
The options Paul mentions should be what you're looking for.

Another approach could be to use the browser's inspector to find a specific class for the editor. (could be something like .tinymce) and override the background in your css

e.g.
.tinymce body {background: none;}

Re: Back Ground Image

Posted: Fri Jul 02, 2021 9:42 am
by Barrowboy
Hi
I have now got back to looking into the issue.

While building the site we just temp removed the BG image but now we have other editors using the site we like to find an answer to the problem.

I believe there must be someway.

We have added this bit of code to the css file.

/* TinyMCE specific rules */
body.mceContentBody { background: #fff; color:#000; }

We have also tried adding this to css background: none !important;

But this seems to have no affect could something be missing?

Thanks for any further ideas.

Re: Back Ground Image

Posted: Fri Jul 02, 2021 7:07 pm
by Dr.CSS
Try using the some code to add the image to take it away...

background-image bla bla bla {none}

Re: Back Ground Image

Posted: Sat Jul 03, 2021 6:52 am
by Barrowboy
Thanks for your suggestion but unable to make it work.

We now have this in the css.

/* TinyMCE specific rules */

body.mceContentBody {
background-image: none !important;
background: #fff; color:#000; }

Is the call correct body.mceContentBody could that be wrong??

Thanks

Re: Back Ground Image

Posted: Wed Jul 07, 2021 12:25 pm
by PinkElephant
Dusting off an old test site and installing TinyMCE... it looks like the editor content is sandboxed in an iframe where the child body can inherit the parent styles (optionally from the CMSMS design) but to override them you need to insert them *within* the child. TinyMCE seems to offer a number of ways of doing that (see Configure the appearance of content inside TinyMCE's editable area). I think the easiest way in this case is to go via javascript...

Extensions > TinyMCE > [profile] > Templates | Extra JavaScript options for the init script

Adding content_style...

Code: Select all

paste_as_text: true,
image_caption: true,
content_style: 'body {background-color:yellow;}'
... does the trick here but you may need to CTRL-F5 to see the change.

Re: Back Ground Image

Posted: Wed Jul 07, 2021 4:18 pm
by Barrowboy
Thanks for your suggestion but unfortunatly it still the same.

I have added one more line to your suggestion.

paste_as_text: true,
image_caption: true,
content_style: 'body {background-image:none;}',
content_style: 'body {background-color:yellow;}'

But still unable to hide the image or get a yellow background.

Cleared the cache and rebooted the system each time but no luck.

I will keep trying but if you have any other ideas I would appreciate it.

Thanks

Re: Back Ground Image

Posted: Wed Jul 07, 2021 4:22 pm
by Barrowboy
Hi again
Just notice that I now have a yellow background on my dropdown css selections.
So its possible the content_style that is wrong.

Thanks

Re: Back Ground Image

Posted: Wed Jul 07, 2021 5:38 pm
by PinkElephant
Barrowboy wrote: Wed Jul 07, 2021 4:22 pmJust notice that I now have a yellow background
Perhaps you didn't refresh the browser -- or a server clear-cache was needed.

It seems to work here...

... adding this to the design's main stylesheet

Code: Select all

body {
  background: url([[root_url]]/uploads/images/logo1.gif) repeat;
}
... makes editing content quite tricky ;)

Updating the default TinyMCE profile with ...

Code: Select all

content_style: 'body {background-color:yellow;background-image:none;}'
... yellow remains and the image disappears (but I did clear the cache and refresh the browser a couple of times).

Re: Back Ground Image

Posted: Wed Jul 07, 2021 5:57 pm
by Barrowboy
Hi Again

Got it Hooray, Hooray.

Change the setting to you last recommendation and yellow to white.

Cleared cache in maintenace, browser, and the server now works. Didn't do server last time.

That's a load of my mind.

Thanks for all your help I hope this helps anyone else with the same issue.

Regards.

Re: Back Ground Image

Posted: Thu Jul 08, 2021 3:01 pm
by PinkElephant
Cool :)

By the way, I only used background-color as an example (and an easy-to-see change in the TinyMCE's handy preview), you can probably run with just one property override...

Code: Select all

content_style: 'body {background-image:none;}'

Re: Back Ground Image

Posted: Thu Jul 08, 2021 4:49 pm
by Barrowboy
Hi
Thanks but I had already done that.

It's nice to have a colour sometimes so you can follow what's going on.

My uses can now see and edit content.