Hugo Image Resize - image

My repo: nataliepjlin/up (github.com)
I want to use the percentage of width to make the image responsive just like the screenshot did.(this was changed in the inspect window)
While using the code on my repository, the rendered image looks like this:
screenshot
So I change the layout/shortcodes/image.html file line 6,7 to {{ $width:= replace (replace (.Get "width") "x" "%") "px" "%" }} , but it came out as error message of execute of template failed: template: shortcodes/image.html:96:31: executing "shortcodes/image.html" at <$image.Resize>: error calling Resize: strconv.Atoi: parsing "50%": invalid syntax
screenshot
Also, I tried codes from Responsive Images in Hugo | Adam Wills using {{< img src="images/blog/shop" type="jpeg" alt="" caption="" >}} in my post, but the image didn't show up.
Is there any modification I can do to fix this? Thanks a lot 🙏🙏

Related

How to right-align text in markdown code block?

I have the following markdown code
<pre>
┣━━ 📦 t_databases - this is text
┃ ┗━━ MongoDB-Go.md - this is text
┗━━ t_webdev
┣━━ editor-Swagger.md
┗━━ packages-Go.md
┗━━ MongoDB-Go.md
</pre>
This looks like this:
How can I make this is text perfectly in line? Is there a programmatic way? Doens't seem to work if I just use tab key.

Unity: Open local file containing a space for windows

I have tried unsuccessfully to open image file that it's name contains a space.
I use the following call:
WWW www = new WWW(url);
where:
url = "C:\Users\user\Documents\Files\Thumbnails\sample image.png";
A red question mark appears instead of image.
Also a 404 error appears when print www.error.
If I use another .png file without space (sampleimage.png), it works perfectly. On Windows and Editor it works nice too.
So I tried to replace the space with %20 but an error "can't load the file" appears.
I have also tried WWW.EscapeURL applied on the filename ... but nothing works.
Try to use verbatim string along with file:// prefix:
string filePrefix = #"file://";
string url = #"C:\Users\user\Documents\Files\Thumbnails\sample image.png";

How do I display local image in markdown?

Does anyone know how to display a local image in markdown? I don't want to set up a webserver for that.
I try the following in markdown, but it doesn't work:
![image](files/Users/jzhang/Desktop/Isolated.png)
I suspect the path is not correct. As mentioned by user7412219 ubuntu and windows deal with path differently. Try to put the image in the same folder as your Notebook and use:
![alt text](Isolated.png "Title")
On windows the desktop should be at: C:\Users\jzhang\Desktop
The following works with a relative path to an image into a subfolder next to the document:
![image info](./pictures/image.png)
Solution for Unix-like operating system.
STEP BY STEP :
Create a directory named like Images and put all the images that will be rendered by the Markdown.
For example, put example.png into Images.
To load example.png that was located under the Images directory before.
![title](Images/example.png)
Note : Images directory must be located under the same directory of your markdown text file which has .md extension.
To add an image in markdown file the .md file and the image should be in the same directory. As in my case my .md file was in doc folder so i also moved the image into the same folder. After that write the following syntax in .md file
![alt text](filename)
like ![Car Image](car.png)
This has worked for me.
The best solution is to provide a path relative to the folder where the md document is located.
Probably a browser is in trouble when it tries to resolve the absolute path of a local file. That can be solved by accessing the file trough a webserver, but even in that situation, the image path has to be right.
Having a folder at the same level of the document, containing all the images, is the cleanest and safest solution.
It will load on GitHub, local, local webserver.
images_folder/img.jpg < works
/images_folder/img.jpg < this will work on webserver's only (please read the note!)
Using the absolute path, the image will be accessible only with a url like this: http://hostname.doesntmatter/image_folder/img.jpg
if image has bracket it won't display
![alt text](Isolated(1).png)
rename the image and remove brackets
![alt text](Isolated-1.png)
Update:
if you have spaces in the file path, you should consider renaming it too or if you use JavaScript you can encode it using
encodeURIComponent(imagePath)
Also, always try to save images and files alike with lowercase, please develop that habit, just my personal view though
Adding a local image worked for me by like so: ![alt text](file://IMG_20181123_115829.jpg)
Without the file:// prefix it did not work (Win10, Notepad++ with MarkdownViewer++ addon)
Edit: I found out it also works with html tags, and that is way better:
<img src="file://IMG_20181123_115829.jpg" alt="alt text" width="200"/>
Edit2: In Atom editor it only works without the file:// prefix. What a mess.
Depending on your tool - you can also inject HTML into markdown.
<img src="./img/Isolated.png">
This assumes your folder structure is:
├── img
└── Isolated.jpg
├── README.md
Edited:
Working for me ( for local image )
![system schema](doc/systemDiagram.jpg)
tree
├── doc
  └── jobsSystemSchema.jpg
├── README.md
markdown file README.md is at the same level as doc directory.
In your case ,your markdown file should be at the same level as the directory files.
Working for me (absolute url with raw path)
![system schema](https://server/group/jobs/raw/master/doc/systemDiagram.jpg)
NOT working for me (url with blob path)
![system schema](https://server/group/jobs/blob/master/doc/systemDiagram.jpg)
Just add the relative image file route from the markdown file
![localImage](./client/src/assets/12.png)
This worked for me in ubuntu:
![Image](/home/gps/Pictures/test.png "a title")
Markdown file is in:
/home/gps/Documents/Markdown/
Image file is in:
/home/gps/Pictures/
To my knowledge, for VSCode on Linux, the local image can be normally displayed only when you put the image into the same folder as your .md post file.
i.e. only ![](image.jpg) or ![](./image.jpg) will work.
Even the absolute path like ![](/home/bala/image.jpg)also doesn't work.
In Jupyter Notebook Markdown, you can use
<img src="RelPathofFolder/File" style="width:800px;height:300px;">
Another possibility for not displayed local image is unintentional indent of the image reference - spaces before ![alt text](file).
This makes it 'code block' instead of 'image inclusion'. Just remove the leading spaces.
You may find following the syntax similar to reference links in markdown handy, especially when you have a text with many displays of the same image:
![optional text description of the image][number]
[number]: URL
For example:
![][1]
![This is an optional description][2]
[1]: /home/jerzy/ComputerScience/Parole/Screenshot_2020-10-13_11-53-29.png
[2]: /home/jerzy/ComputerScience/Parole/Screenshot_2020-10-13_11-53-30.png
I've had problems with inserting images in R Markdown. If I do the entire URL: C:/Users/Me/Desktop/Project/images/image.png it tends to work. Otherwise, I have to put the markdown in either the same directory as the image or in an ancestor directory to it. It appears that the declared knitting directory is ignored when referencing images.
Either put the image in the same folder as the markdown file or use a relative path to the image.
just copy the image and then paste it, you will get the output
![image.png](attachment:image.png)
The basic syntax is ![Image description](Any_Image_of_your_choice.png "title"). In my case, I used image name as Any\ Image\ of\ your\ choice.png in ![Image description](Any\ Image\ of\ your\ choice.png) instead of ![Image description](Any_Image_of_your_choice.png) and it was not working. So I would say make sure to check the image directory and also image name doesn't contain spaces if so use underscore(_) instead of space.
Faced issue while using markdown in Jupyter notebook in Ubuntu 18.04.
I got a solution:
a) Example Internet:
![image info e.g. Alt](URL Internet to Images.jpg "Image Description")
b) Example local Image:
![image Info](file:///<Path to your File><image>.jpg "Image Description")
![image Info](file:///C:/Users/<name>/Pictures/<image>.jpg "Image Description")
TurboByte

Align image caption with image in asciidoc

I have a block image inserted as shown below:
[[myimage]]
image::fig1.png[align="center", title="My caption"]
Unfortunately, the image is centered but the caption is left-aligned. I also tried doing this:
[[myimage]]
.My caption
image::fig1.png[align="center"]
but the result does not change. How can I get the image caption to also be center-aligned?
I am generating HTML output with this command (using xhtml11 as backend makes no difference):
asciidoc -v -a asciimath -d article -b html5 -o file.html file.txt
Change the CSS style sheet to do the alignment for you.
Create directory themes in your working directory then download this file into themes
Modify the captions align from left to center as below:
caption:
align: center
Specify theme file when generating pdf
asciidoctor-pdf ${adoc_file} -o ${output_pdf} -a pdf-stylesdir=themes
-a pdf-style=custom-theme.yml

wget wikimedia image?

I am trying to download an image from Wikimedia Commons by using a URL to a page in the file namespace:
wget http://commons.wikimedia.org/wiki/File:A_golden_tree_during_the_golden_season.JPG
all I get is a JPG file that I cannot open. But when you go to the link you actually see the page instead of the image itself, but there is a link called "Full resolution" that sends you to the real image link which is: http://upload.wikimedia.org/wikipedia/commons/9/92/A_golden_tree_during_the_golden_season.JPG
How can I download this file by having only the first link ?
You can try the following:
wget http://commons.wikimedia.org/wiki/File:A_golden_tree_during_the_golden_season.JPG -O output.html; wget $(cat output.html | grep fullMedia | sed 's/\(.*href="\/\/\)\([^ ]*\)\(" class.*\)/\2/g')
The first wget fetches the link you specify. I browsed few pages and found that high resolution images were under div with class=fullMedia. It parses the url of the image and then fetches that image.
PS: As suggested above, bash is not a neat way of doing this. You should look at something that parses dom trees.
Extract the title without namespace (A_golden_tree_during_the_golden_season.JPG) and pass it to Special:Redirect.
wget http://commons.wikimedia.org/wiki/Special:Redirect/file/$( echo 'http://commons.wikimedia.org/wiki/File:A_golden_tree_during_the_golden_season.JPG' | sed 's/.*\/File\:\(.*\)/\1/g' )
wget http://upload.wikimedia.org/wikipedia/commons/9/92/A_golden_tree_during_the_golden_season.JPG
You were fetching the web page not the image itself.
you can use the following link to retrive :https://upload.wikimedia.org/wikipedia/commons/9/92/A_golden_tree_during_the_golden_season.JPG
Even I had got the same problem,click on the image you will get the above link ,i hope this helps

Resources