I am having trouble getting ckeditor to properly resize images in my Rails application. When I look at the html in it appears that the height and width parameters are not showing up. When I leave the text unsanitized in rails the height and width parameters appear as below, which is obviously is using a colon in lieu of "=" followed by a number in " ".
<img alt="" src="/ckeditor_assets/pictures/1/content_world.png" style="float: left; width: 100px; height: 100px; " />
Does anyone have any clue how this can be adjusted somewhere in the config.js or somewhere else that will cause these parameters to result in proper html?
Thanks for any help!
The default configuration of CKEditor sets the image size in the style (yes, I don't like either, let's not argue about it).
You can look at the "Output HTML" sample to get the code to generate width and height attributes instead.
Related
I use a Div as follows:
html = '<h1>Thi is my title</h1>'
div = hv.Div(html)
but the result is
<div class="bk bk-clearfix" style="display: inline-block; width: 300px; height: 300px;">This is my title</div>
Any idea why? No header tag, but the title inside a stupid 300×300px div.
I can replicate those results in a Jupyter notebook with:
import holoviews as hv
hv.extension("bokeh")
html = '<h1>This is my <i>title</i></h1>'
hv.Div(html)
The 300x300 box is because a Div is meant to be used alongside other plots, each with a fixed (though sometimes responsive) size. You can add .opts(height=100) or .opts(sizing_mode="...") (with various options for ...) to the div to control the sizing, though I haven't seen any option for "whatever size the content actually is".
In any case the missing markup is a bug in recent HoloViews releases, because Bokeh itself handles the markup just fine (see e.g. https://docs.bokeh.org/en/2.4.0/docs/user_guide/interaction/widgets.html#div), while HoloViews appears to be stripping out all the markup (https://holoviews.org/reference/elements/bokeh/Div.html). This has been reported as a bug in HoloViews (https://github.com/holoviz/holoviews/issues/4743).
A client asked me to look into a problem he is having on his WP site.
When adding an external image into a post, with an original size of 800x640.
You can resize the image via the Wordpress wysiwyg editor to, say 400x320.
the html part will look something like this when inspecing the element with firebug on front end or in the text tab of the editor:
<img class="" src="http://xxx.nl/images/externalimage.jpg" alt="" width="400" height="320" />
But on the front end the image is shown at its original 800x640 size.
When inspecting the element with firebug it shows:
img {
height: auto;
max-width: 100%;
vertical-align: top;
width: auto;
}
If I disable the 'width' line in firebug
The image resizes to 400x320.
How can I resolve this issue, so that the client can just do his thing with the images in the editor.
I can solve it myself on a individual case basis by adding a width to the containing span/p tag, but the client doesn't know css or html and I can't manually edit all the widths of the containing tags every time he posts something new.
The images will always be inside the 'post' wrap container, which has its own class. But apart from auto, I only set it to 'inherit' but this yields the same result as auto. (I guess it will inherit -> auto from the img {})
I don't know what I'm doing wrong here, seems quite an easy question.
I'm adding img tags to the navigation label field in the menus section in order to create some social media buttons. I want them to be 25px by 25px, but I want them to be ready for retina screens, so the images I'm uploading are 50 by 50px.
The annoying thing is, I actually managed to do this about 3 hours ago, but since coming back to it, they're no longer re-sizing and I'm just left with a massive icon.
The code I was using to scale them down was:
<img src=“url here” height=“25” width=“25”>
Is there a way of fixing this, or an easier way to achieve what I'm trying to do?
Thanks
You are using stylized quotation marks in your code.
<img src=“url here” height=“25” width=“25”>
This is invalid HTML. Did you copy and paste the code from MS Word? That's sometimes the reason.
You need unformatted characters, which basic text editors provide.
Keep the quotation marks simple and basic:
<img src="url here" height="25" width="25">
These are ASCII quote marks which are valid HTML.
Although quote marks are optional in HTML5, I would recommend always using them as a best practice. Here are some reasons why: Do you quote HTML5 attributes?
Remove those inline heights and widths from the HTML and do this:
/*using the parent class as the hook for specificity*/
.parent img{
width: 100%;
max-width:25px;
height: 100%;
max-height:25px;
}
This guarantees the image will respect the 25px X 25px size. Not smaller, not bigger.
** If your CSS is overwriting it, you may have a !important rule to clean up.
This is a relatively small project that I've been working on however it's driving me insane...
I'm trying to port my original website (which was done completely in Dreamweaver, HTML) to a Visual Studio 2013 ASP.NET project where I can add databases, login's etc. for an assignment I have.
The main problem I have is the fact that my CSS code does not want to do what I tell it to do in terms of the layout.
I've tried completely remaking the website entirely step by step, making sure each aspect works correctly before moving on to the next.
This is what my original website looks like:
http://i.stack.imgur.com/sxfeg.png
(Original HTML + CSS) https://gist.github.com/anonymous/7ed94218f9374d41918e
Now, I used a template a long time back in order to get this design and I've experimented to see which CSS code affects the layout and found that the tag main_container (line 13 of the HTML gist) controls the white background of the website.
So if I remove the tag, this will happen: http://i.stack.imgur.com/BFNLE.png
^ This is important in my problem.
When porting over my website, I copied across all the code correctly and adapted it to ASP. (See Gist: https://gist.github.com/anonymous/9c09befeb8950f4c1416)
However, in doing so, I encountered a problem where the CSS code for the main_container was not being used correctly.
#main_container{
width:977px;
background:url(center_bg_repeat.gif) repeat-y center;
The image was not being repeated on the y axis like on the original website and here's the result: http://i.stack.imgur.com/E4TZU.png
Have I got the syntax wrong? Or what is wrong with my code?
I've placed all the images in the same folder as the CSS file for
convenience.
Is this a problem with Visual Studio 2013 or am I doing something
fundamentally wrong?
Is there perhaps another way to port this same design without
causing so many problems?
I'm not entirely clear on what you want to achieve but if it is the same layout as your original site, then it is better to replicate the html and css exactly first to get it working then look at restructuring or refactoring the code. For example, check that all element sizing is the same so that content displays as you expect.
There are a couple of key differences between your original and new code that could affect the behaviour in the new version of your site. In your original css you don't have a repeat style for center_bg_repeat.gif. Also, it looks like #main_container isn't referenced in your original code.
Repeating a background image won't cause content to repeat across the page. You are already including your content in your new html so you just need to use positioning (e.g. floats vs relative/absolute positioning) to get the tiles to layout in the way you want (see code snippet for an example).
html, body, .container
{
height: 100%;
min-height: 100%;
}
.tile {
float: left;
width: 20%;
height: 30%;
margin: 10px;
padding: 20px;
background-color: #ccc;
}
<div class="container">
<div class="tile">first</div>
<div class="tile">third</div>
<div class="tile">second</div>
<div class="tile">fourth</div>
<div class="tile">last</div>
</div>
In your case, if you want #main_container to scale to fit the content then set its style to min-height: 100%;
I'm create a custom wysiwyg editor, with custom variables which are filled in from PHP after the content is saved.
For example {image} is a placeholder, which will be filled from PHP after the content saved.
In this case my content template in the HTML code looks like this
<img src="{image}" />
As this is some kind of drag and drop system, I should be able to drag this item on the wysiwyg canvas, but as that {image} placeholder can't be filled with javascript, the browser won't be able to load any image. As I know in this some old Internet explorer versions give some default "image broken" image into those img's, but modern browsers simply doesn't display it.
So is there any way to make those unloaded images visible(by giving some width and height value and some magic)?
I would like to make this with simple CSS rules without using javascript.
One solution what I have found is to give alt attribute to the images and then that text gives with and height for that element.
You should use onerror.. so the image will fail to load, but you can then display a 'holding image' to show the end-user that it will be replaced with their real image when published..
<img src="{image}" onerror="this.src='http://www.mnit.ac.in/new/PortalProfile/images/faculty/noimage.jpg';" width="100" height="100" />
Change the URL to yours.. so something like
<img src="{image}" onerror="this.src='/images/temp_image.jpg';" width="100" height="100 />
Example: http://jsfiddle.net/7FtfX/
Setting the width and height attributes directly on the img element to some modest placeholder size is probably the way to go. You can also do it CSS, i.e:
.wsyiwyg img {
width: 100px;
height: 100px;
background-color: #787878;
margin: 5px;
}
Another idea which might be better is to use JS to check on all img elements and parse the src attribute, then replace any with the {image} format with a placeholder image src (but save the original data and switch it back on save/submit).
Use width, height properties and background. Look at sample