Adding images to react/gatsby markdown html/md mixed files - html

Part 1:
I have been searching for a while now and have found a few options that work in markdown but not how I would like. I am looking for a way to add images to a markdown files HTML.
Currently this works in the md files:
![description](../img/splash/homepage-tall.jpg)
But, I am trying to add a class to the above with no success.
What I have tried so far:
![img description][../img/splash/homepage-tall.jpg]{: .img-fluid }
![img description](../img/splash/homepage-tall.jpg){.img-fluid}
![img description][../img/splash/homepage-tall.jpg]{: class=img-fluid }
Can a class be added to markdown?
Part 2:
I even tried going the direct HTML route but, the relative path does not work. Is there a way to link the images using HTML in a markdown file?
<img class="module" src="../img/splash/homepage-tall.jpg" alt=" "/>

Related

Why isn't the CSS id working in the dv? Have I made a mistake of some sort?

I'm new to both HTML and CCS (I've just started yesterday night) and have hit a snag. I'm having some trouble with using the id selector in the div; the background image is failing to appear. Please note that external ccs was used and the image in question exists in a separate folder. Also, the code seen below was made using notepad on my Microsoft computer.
Here's what I've got so far:
#banner {
background-image: url("../img/Sunflower.jpg");
background-repeat: no repeat;
background-size: cover;
}
<link rel="stylesheet" href="css/style.css">
<div id = "banner">
Google Search
<br>
YouTube
<h1>First Web Page</h1>
</div>
There are several things that can go wrong:
In your CSS, you used a relative URL. Usually, Images are transfered over the web via HTTP, so usually, we put relative paths only when we use a bundler for JavaScript/Css. I recommend you change your image path to /img/Sunflower.jpg This will make your web-browser request it at <server_root>/img/Sunflower.jpg
Maybe you didn't include the actual CSS path in the HTML file to make the browser actually fetch it. Please check the <link> tag
The code you've written is generally okay, so the problem is with your actual filesystem / understanding of server paths, so I recommend checking those out.
Here's a working example for you:
#banner {
background-image: url("http://via.placeholder.com/300");
background-repeat: no-repeat;
background-size: cover;
}
<div id="banner">
Google Search
<br>
YouTube
<h1>First Web Page</h1>
</div>
Your code is correct and should work. Please consider the following.
1: Make sure you have the correct path of the image. Your path looks good from here, however, it is still hard to say because we don't know where you have saved the image.
2: Check and be sure that you have linked your CSS to your Html file if using the external CSS, or they are correctly placed in style tag if using internal CSS.
Thank you.
are you using inline css or external css file, or make a separate folder to your media and use that objects by giving simple names like img1.png like that
no-repeat instead of no repeat
please remowe spaces around equation marks - I've never seen anybody formatting the code like that
path to the image is most likely incorrect. Bear in mind ../ means one folder up relative to the css file
did you include your css file in HTML file?
Try add this line on header of HTML file:
<link rel="stylesheet" href="styles.css" />
where "styles.css" is the name of your css file. Check if the css file is in the same folder too.

I don't understand why my Css code for background-image does not work

It seems like a very easy task and that's exactly how it is done on some websites with examples but it just does not work for me!
My folder is like this:
project
resources
css
index.css
images
pattern.jpeg
other.jpeg
another.jpeg
index.html
I need to make a background for some text.
CSS:
#company-name{
background-image: url("resources/images/pattern.jpeg");
}
html:
<h1 id="company-name">Dasmoto's Arts & Crafts</h1>
My html can see the picture, i've checked it by putting it in here:
<img src="resources/images/hacksaw.jpeg"/>
just in src"" - and the picture was shown normally as it is supposed to.
Also just to check if CSS can understand my ID from HTML - instead of backbround-image - I chenged the color and it did work so ID is fine.
Remember your CSS and HTML are accessing the image from different positions in the project. The index.html and the resources folder are on the same level so can be reached using the path you've provided.
In order to locate the image from the css, you'll either need to begin your search from the root like so:
background-image: url('/resources/images/pattern.jpeg');
or begin by coming out of the css directory like so:
background-image: url('../images/pattern.jpeg');

relative import of an svg in an image tag angular 4

I have an angular 4 app I am trying to import an SVG file into an html file inside an image tag
i.e
<img src="../app/scalableVectorGraphics/landingpage/twitter.svg">
the path to the html file:
suitsandtables/frontend/suitsandtables-app/src/app/browsevenues/venuelist/venuelist.component.html
the path to the svg file:
/app/scalableVectorGraphics/landingpage/twitter.svg
I have tried
/app/scalableVectorGraphics/landingpage/twitter.svg
./app/scalableVectorGraphics/landingpage/twitter.svg
../app/scalableVectorGraphics/landingpage/twitter.svg
is there something I am missing in importing SVG files as images. This seemed to be pretty straight forward.
Put your images in src/assets/scalableVectorGraphics/... and then :
HTML
<img src="assets/scalableVectorGraphics/landingpage/twitter.svg">
If you need to put in stylesheet as background image:
CSS:
background-image: url(/assets/scalableVectorGraphics/landingpage/twitter.svg)
After none of the responses from stack & different websites worked, for me ::before has done the job:
div::before {
content: url('../assets/images/Office\ Health\ Logo.svg');
}

Inline CSS in Markdown

I'm using Simplemde ( markdown editor ) as an embdedded textarea for writing articles in my website. I've recently encountered a problem :
While writing, if I insert an image , it stretches to 100%, taking over the entire page, like this :
I tried inserting inline css (style tags) in the textarea, but that didn't work.
However in the preview option, I used inline css (set height and width at 400px ) and it worked :
How can I set the image size as per my preference in this markdown editor ?
UPDATE : I already tried embedding HTML in Markdown ,like :
<img style="width:400px;" src="abc.jpg">
But this doesn't seem to work, and my the image doesn't even appear in the article this way. The entire img tag gets shrinked to <img> in my textarea!
Embedding CSS in Markdown is easy. It may depend on the markdown parser but usually one can include any valid HTML and CSS in markdown files.
<style type="text/css" rel="stylesheet">
* { color: red; }
</style>
This is a markdown file. Save this snipped under `test.md` and convert into html5
with `pandoc` or any other markdown parser.
A very powerful markdown parser is pandoc!
pandoc --from=markdown --to=html5 --output=test.html test.md
This might be able to answer your question, it looks like you can embed HTML in markdown and you can add styles that way. Markdown and image alignment
You said you tried inline, did you try just HTML?
<img src="https://i.imgur.com/sZlktY7.png" width="50">

Resize image in the wiki of GitHub using Markdown

I'm writing a wiki page on GitHub, and I'm using Markdown.
My problem is that I'm putting a large image (this image is in its own repository) and I need resize it.
I have tried different solutions, but they do not work:
![image](http://url.to/image.png "Title" {width=40px height=400px})
![image](http://url.to/image.png = 250x250)
![image](http://url.to/image.png = 250x)
[[http://url.to/image.png = 250x]]
Is there a way to get it?
It is preferable without HTML.
Updated:
Markdown syntax for images (external/internal):
![test](https://github.com/favicon.ico)
HTML code for sizing images (internal/external):
<img src="https://github.com/favicon.ico" width="48">
Example:
Old Answer:
This should work:
[[ http://url.to/image.png | height = 100px ]]
Source: https://guides.github.com/features/mastering-markdown/
On GitHub, you can use HTML directly instead of Markdown:
<img src="http://url.to/image.png" align="left" height="48" width="48" >
This should make it.
Resize by Percentage width=50% height=50%. Example:
<img src="https://i.imgur.com/ZWnhY9T.png" width=50% height=50%>
Resize by Pixels width="150" height="280". Example:
<img src="https://i.imgur.com/ZWnhY9T.png" width="150" height="280">
Some tips
To get a githubusercontent link for an image, drag and drop the image into any issue, and copy/paste the url from the code that is automatically generated. Example code: ![image](https://user-images.githubusercontent.com/16319829/81180309-2b51f000-8fee-11ea-8a78-ddfe8c3412a7.png)
There is no way to change the size of an image if the markdown format is of the form []() - so stop looking right now! - you must use <img> instead
Another useful summary of conventions that do and don't work here
All of the above is from here
Almost 5 years after only the direct HTML formatting works for images on GitHub and other markdown options still prevent images from loading when specifying some custom sizes even with the wrong dimensions.
I prefer to specify the desired width and get the height calculated automatically, for example,
<img src="https://github.com/your_image.png" alt="Your image title" width="250"/>
I have used methods described above. Now I am using the method which is a way similiar but more simple to me.
First create add README.md file to your project.
Then upload screenshoots or whatever description images needed to your project main directory.
After uploading image Assets use html to refer these assets directly without using link like below
Like this:
<img src="icon.jpg" width="324" height="324">
<p align="center">
<img src="screen1.png" width="256" height="455">
<img src="screen2.png" width="256" height="455">
<img src="screen3.png" width="256" height="455">
</p>
On above example I have used paragraph to align images side by side. If you are going to use single image just use the code as below
<img src="icon.jpg" width="324" height="324">
Have a nice day!
GitHub Pages now uses kramdown as its markdown engine so you can use the following syntax:
Here is an inline ![smiley](smiley.png){:height="36px" width="36px"}.
http://kramdown.gettalong.org/syntax.html#images
I haven't tested it on GitHub wiki though.
You can tried to put the image into table of markdown, like this:
| ![Kiku](docs/snapshot/home.jpeg) | ![Kiku](docs/snapshot/sub.jpeg) |
| --------------------------------------- | --------------------------------------- |
| ![Kiku](docs/snapshot/user-center.jpeg) | |
it will make the image layout like grid, but it could not custom for each single image size.
This addresses the different question, how to get images in gist (as opposed to github) markdown in the first place ?
In December 2015, it seems that only links to files on
github.com or cloud.githubusercontent.com or the like work.
Steps that worked for me in a gist:
Make a gist, say Mygist.md (and optionally more files)
Go to the "Write Comment" box at the end
Click "Attach files ... by selecting them"; select your local image file
GitHub echos a long long string where it put the image, e.g.
![khan-lasso-squared](https://cloud.githubusercontent.com/assets/1280390/12011119/596fdca4-acc2-11e5-84d0-4878164e04bb.png)
Cut-paste that by hand into your Mygist.md.
But: GitHub people may change this behavior tomorrow, without documenting it.