cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How can I embed image to the cell using markdown or code?

YosepWijaya
New Contributor II

I have been trying to embed the image from the dbfs location, when I run the code, the image is unknown or question mark.

I have tried following code:

The path of the file is dbfs:/FileStore/tables/svm.jpg

displayHTML("<img src ='dbfs:/FileStore/tables/svm.jpg'>")

displayHTML("<img src ='/FileStore/tables/svm.jpg'>")

7 REPLIES 7

PohlPosition
Databricks Employee
Databricks Employee

@Yosep Wijaya

When you write the image to DBFS, you should write it to /FileStore/svm.jpg

When you reference the file in html, it should be via /files/svm.jpg

@jason Thanks!! than

VenkataMoganti
New Contributor II

capture.pngAdd files before the path

Use this format to add the file

![Name of the image](files/tables/svm.jpg)

please check this https://docs.databricks.com/data/filestore.html

AlexBrulliea
New Contributor II

Is there a way to embed an image from mounted storage into my markdown cell? Or can this only be done using the dbfs files?

rs-tcs
New Contributor II

I strongly miss the Jupyter Notebook style CTRL+C and CTRL+V paste where I can copy the image from the MS Paint and then paste directly into the cell which then transforms the raw bytes into base64 encoded string, without having to reference via a link.   

WiliamRosa
New Contributor II

Hi everyone,

Hereโ€™s an easy way to embed images into Databricks notebook cells, using markdown or code:

1. Drag and drop images directly into Markdown cells

You can simply drag an image file from your local system into a markdown cell. Databricks will upload it automatically to your workspace directory and display it inline in the cell.

2. Reference images stored in the workspace or volumes

If your image already resides in the workspace storage or a Unity Catalog volume, you can display it using standard markdown syntax. Use either an absolute path (starting from the root of the workspace or volume) or a relative path. For example:

%md
![description](/Workspace/absolute/path/to/your_image.png)


or

%md
![description](./relative/path/to/your_image.png)


Similarly, reference images stored in volumes with an absolute volume path:

%md
![description](/Volumes/absolute/path/to/your_image.png)

3. Use displayHTML to render custom HTML including images

If you need more controlโ€”like sizing or positioningโ€”you can use HTML in your notebook. Use the displayHTML() function to render custom HTML, including <img> tags. For example:

displayHTML('<img src="/Workspace/absolute/path/to/your_image.png" width="300" />')

Wiliam Rosa
Data Engineer | Machine Learning Engineer
LinkedIn: linkedin.com/in/wiliamrosa

BS_THE_ANALYST
Honored Contributor III

@WiliamRosa 

You've stated:

"1. Drag and drop images directly into Markdown cells

You can simply drag an image file from your local system into a markdown cell. Databricks will upload it automatically to your workspace directory and display it inline in the cell."


Are you sure on that?

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now