I need to resize a local image from the assets folder in my markdown file.
I currently have this image that does display in my .md file.
I need to resize the image to make it a bit smaller.
Is it possible with the current package?
You can use inline HTML <img/> with providing size.
<img src = "assets/images/image01.png" width="x" height="x" />
Or
[<img src ="assets/images/image01.png" width="100" height="x"/> ](assets/images/image01.png)
More and ref: Changing image size in Markdown
<img src="drawing.jpg" alt="drawing" width="200"/>
This the github discussion on this, https://gist.github.com/uupaa/f77d2bcf4dc7a294d109
Related
I recently added a video on a readme file on GitHub. Although I was able to drag and drop the video, it automatically fills the entire width of the readme. I was wondering if there was a way to adjust the height and width the video?
I'm not entirely sure what you mean by "I was able to drag and drop the video", but assuming that generates a <video> tag you should be able to add a height or width attribute to it, e.g. as shown in the MDN documentation:
<video controls width="250">
<!-- ^^^^^^^^^^^ -->
<source src="/media/cc0-videos/flower.webm" type="video/webm">
<source src="/media/cc0-videos/flower.mp4" type="video/mp4">
Sorry, your browser doesn't support embedded videos.
</video>
I have an issue with displaying plots with .ofig extension in markdown. Figures are located in assets dir and I cannot display them in local preview nor when I push on GitHub.
Does anyone have any suggestions how can I achieve that or will I need to convert the plots in another format?
I have tried:
<img src="assets/SIR-figure-1.ofig" width="auto" height="auto" />
<img src="assets/SIR-figure-1" width="auto" height="auto" />
![plot](assets/SIR-figure-1.ofig)
![plot](./assets/SIR-figure-1.ofig)
None of them worked.
GitHub renders Markdown to HTML, so you need to use an image format that web browsers know how to interpret.
Looking at the documentation, I can't tell what ofig actually is but I'm fairly sure it's not browser-friendly. Save your plots as PNG or SVG files instead.
(JPEGs and GIFs would technically work, too, but are unlikely to be good choices here. Most plots will have lots of unsightly artifacts when saved as JPEGs, and unless you need animation PNG is pretty much a more modern GIF.)
I created a Github page following this tutorial: https://guides.github.com/features/pages/
I have my index.md and _config.yml file. I added a /images/font-awesome/address-card-solid.svg file to add this image https://fontawesome.com/icons/address-card.
I displayed the image by adding this to index.md
![useful image]({{ site.url }}/images/font-awesome/address-card-solid.svg)
It displays properly when I go to the site (username.github.io). But the image scales and takes up the whole screen, and also is only black and white in color. How do I make the image smaller and change the color of it? I am using Github markdown (modifying index.md file).
I tried importing the font-awesome CDN and using HTML to display the image but that does not show anything (as expected, as I am in a .md file).
You can use CSS, set color, or backgroundcolor. Be aware that the SVG includes a path object that maybe need also the CSS class.
<!DOCTYPE html>
<html>
<head>
<style>
img {
background-color: #FFFFFF;
}
</style>
</head>
<body>
<p align="center"><img src="image.svg" /></p>
</body>
</html>
This will set the background white only for the specified image in a .md file, it should support other css stuff as well did not try.
Is there any option to include an image in a readme.md file, which has a usemap attribute?
Pure html would be
<img src="myimage.png" usemap="#mymap"/>
<map name="mymap">
<area coords="1,1,40,40" href="mylink.html"/>
</map>
I can't get that to work for multiple reasons
usemap is retained as attribute but the map-block is removed. Not surprising as the map-tag is not on the html whitelist, if I am not mistaken.
An image map cannot be inside an anchor tag but github markdown renders it as
a-tag pointing to the raw file location and the img-tag inside.
I don't see any option, do you?
Okay, sort of a solution and the advice to use CSS, not img's usemap attribute.
The best answer I came up with was using github pages - these are static web pages hosted by github and therefore you can do everything you want there.
https://help.github.com/articles/creating-a-github-pages-site-with-the-jekyll-theme-chooser/
This creates a new branch gh-pages and only those html files are used. Very convenient as you do not have to checkin into the master branch for changes.
The endresult is not an image map inside the README.MD file, but there I have added a link to the github-pages index.html which is using the imagemap. The imagemap points back to the various github resources. So not inline the README.MD but one click away.
Second finding: Don't use image maps but CSS instead. Imagemap coords depend on the width of the image as rendered by the browser, not on the width of the image itself. As in github the standard is to use a max-width style property, the image often gets scaled down - and the coords of the imagemap are not.
Much better to use CSS - see "responsive image maps" - and percent values.
<p style="position: relative;">
<img ....>
<a style="position: absolute; top: 10%; left: 10%; width: 30%; height: 15%" href=....></a>
</p>
As both, the image and the anchor tag are inside a block element which is of position relative and the anchor tag is of position absolute, the anchor position is scaled with the image.
When github.com renders an image in a readme.md, it automatically links the image in an a tag.
Using either
![][http://example.com/path/image]
or
<img src="http://example.com/path/image" />
The actual rendered content will appear as
<img src="https://camo.githubusercontent.com/8a545f12e16ff12f..." alt="" data-canonical-src="http://example.com/path/image" style="max-width:100%;">
I understand the github image caching (on camo.githubusercontent.com), and that's fine, but I don't want the a tag to wrap my image.
I'm not sure if this is part of the github flavored automatic URL linking, or something specific images.
I am able to provide my own link (using my own a tag), but what I really want is no link, no a tag.
Is this possible?
thanks!
You can wrap the image in a link that points to #:
[![](http://example.com/path/image)](#)
<img src="http://example.com/path/image" />
It will still be clickable, but won't open a new page, at least.
You can use the <picture> tag to prevent GitHub from auto linking to the image.
<picture>
<img alt="Image Alt Text" src="http://example.com/path/image">
</picture>
Pass linkImagesToOriginal: false to gatsby-remark-images should be able to resolve this issue.
{
resolve: 'gatsby-remark-images',
options: {
linkImagesToOriginal: false,
},
}
If you click on your badge, you think to see an image, but it is usually a html page with html-tags. That's why badges links to a different page by default.
#Tamás Sengel answer isn't bad, but looks like there were side effects like visual glitches #Igor mentioned.
I solved this problem by simply referring to my github page:
[![platform](https://img.shields.io/badge/platform-ubuntu%20%7C%20windows-lightgrey?style=flat-square)](https://github.com/Ismoh/NoitaMP)
It's a static badge build with shields.io and shouldn't link to source.
The snippet below is exactly what you need to "remove" the a tag for images. Markdown will render all the img's tags around the a. For me (using Gatsby) the option "linkImagesToOriginal: false" removed perfectly and now all the images are NOT clickable.
{
resolve: 'gatsby-remark-images',
options: {
linkImagesToOriginal: false,
},
}
This method works the best for me: linking the image to itself
<a id="image1" href="#image1"><img alt="alt text" src="http://example.com/path/image.png" /></a>