In LookML, you can add an image using a URL by leveraging the html parameter within a dimension or measure. This allows you to render an image in the Looker UI by embedding an HTML <img> tag with the URL of the image. Here's how you can do it:
Example: Adding an Image Using a URL in LookML
lookml
dimension: product_image {
type: string
sql: ${TABLE}.image_url ;; # Assuming your table has a column with image URLs
html: <img src="{{ value }}" height="100" width="100" /> ;;
}
Explanation of the Code:
dimension: product_image:
This defines a dimension in your LookML model. You can name it anything relevant, such as product_image, logo, etc.
type: string:
The type is set to string because the URL is a string value.
sql: ${TABLE}.image_url:
This references the column in your database table that contains the image URLs. Replace image_url with the actual column name in your table.
html: <img src="{{ value }}" height="100" width="100" />:
The html parameter allows you to define custom HTML rendering for the dimension.
{{ value }} is a Liquid variable that dynamically inserts the value of the dimension (in this case, the image URL) into the HTML.
The <img> tag is used to render the image, with src pointing to the URL.
height and width attributes are optional and can be adjusted to control the size of the image in the Looker UI.
Steps to Use This in Looker:
Add the above LookML code to your LookML view file.
Save the file and ensure there are no syntax errors.
In the Looker Explore UI, add the product_image dimension to your query.
Run the query, and the images will be rendered in the results table where the URLs are valid.
Notes:
Image URL Column: Ensure that the column referenced in the sql parameter (image_url in this example) contains valid URLs pointing to publicly accessible images. If the images are behind authentication, they may not render in Looker.
Security: Be cautious when rendering images from user-provided URLs to avoid security risks like XSS (cross-site scripting).
Styling: You can further customize the image rendering by adding CSS styles within the html parameter, such as style="border: 1px solid black;".
Dynamic URLs: If the image URL is not stored directly in the database but needs to be constructed dynamically, you can use Liquid templating to build the URL. For example:
lookml
dimension: product_image {
type: string
sql: ${TABLE}.product_id ;; # Example: Using a product ID to construct the URL
html: <img src="https://example.com/images/{{ value }}.jpg" height="100" width="100" /> ;;
}
In this case, the URL is constructed by appending the product_id to a base URL.
Example with a Static URL:
If you want to display a static image (not tied to a database column), you can hardcode the URL:
lookml
dimension: static_image {
type: string
sql: 'static' ;; # Dummy SQL value since the URL is static
html: <img src="https://example.com/static-image.jpg" height="100" width="100" /> ;;
}
Testing and Debugging:
Ensure the image URLs are valid and accessible. You can test the URL in a browser to confirm the image loads.
If images do not render, check the browser's developer console for errors (e.g., 404 Not Found, CORS issues, etc.).
By following these steps, you can successfully add and render images in Looker using URLs in LookML.
User
do it in the dashboard by using markdown
Assistant
In Looker, you can add images to a dashboard using markdown in a text tile. Text tiles support markdown syntax, which allows you to embed images using a URL. Here's how you can do it:
Steps to Add an Image to a Looker Dashboard Using Markdown
Create or Edit a Dashboard:
Navigate to the dashboard where you want to add the image.
If you're creating a new dashboard, click "New Dashboard" in Looker. If you're editing an existing one, click the "Edit" button (pencil icon) on the dashboard.
Add a Text Tile:
In the dashboard edit mode, click the "Add Tile" button (usually a "+" icon).
Select "Text" to add a text tile to the dashboard.
Use Markdown to Embed the Image:
In the text tile editor, use the following markdown syntax to embed an image using a URL:
markdown

Replace https://example.com/image.jpg with the actual URL of the image you want to display.
Replace Alt text with a description of the image (this is used for accessibility and will be displayed if the image fails to load).
Optional: Customize Image Size:
Markdown itself does not support resizing images directly, but Looker allows you to use HTML within text tiles. To control the size of the image, you can use an HTML <img> tag instead of markdown:
Adjust the height and width attributes to control the size of the image.
Save the Text Tile:
After adding the markdown or HTML, click "Save" or "Done" in the text tile editor to save your changes.
Save the Dashboard:
Once you're satisfied with the layout and content of the dashboard, click "Save" to save the dashboard.
Example: Full Text Tile Content
Here’s an example of what the content of a text tile might look like:
User
i only want the upper 50% of the image
Assistant
To display only the upper 50% of an image in a Looker dashboard text tile, you can use HTML and CSS to crop the image. Looker's text tiles support HTML and inline CSS, which allows you to manipulate how the image is displayed. Here's how you can achieve this:
Steps to Display the Upper 50% of an Image
Add a Text Tile to the Dashboard:
Follow the steps from the previous response to add a text tile to your dashboard.
Use HTML and CSS to Crop the Image:
Use an <img> tag wrapped in a <div> container.
Apply CSS to the <div> to control the visible portion of the image by setting overflow: hidden and adjusting the height to 50% of the image's original height.
Use object-fit and object-position on the <img> tag to ensure the image is positioned correctly.
width: 100%: Ensures the container takes up the full width of the text tile.
height: 100px: Sets the height of the visible area. Adjust this value to control how much of the image is shown (e.g., set it to half the height of the original image to show the upper 50%).
overflow: hidden: Hides any part of the image that extends beyond the container's boundaries.
<img> Tag:
src="https://example.com/image.jpg": Replace this with the actual URL of your image.
alt="Cropped Image": Provides an accessible description of the image.
width: 100%: Ensures the image scales to fit the container's width.
: Maintains the image's aspect ratio.
Using Markdown:
markdown
# Dashboard Title
Here is an image:

Using HTML for More Control:
html
<h1>Dashboard Title</h1>
<p>Here is an image:</p>
<img src="https://example.com/logo.png" alt="Company Logo" height="200" width="200" style="border: 1px solid black;" />
Notes:
Image Accessibility: Ensure the image URL is publicly accessible. If the image is behind authentication or on a private server, it may not render in the dashboard.
Styling: You can add inline CSS within the <img> tag (e.g., style="border: 1px solid black;") to further customize the appearance of the image.
Dynamic Images: If you want to display dynamic images (e.g., based on data), you would need to use LookML to create a dimension or measure (as described in the previous response) and then reference that in a visualization tile, not a text tile. Text tiles are static and do not support dynamic data.
Markdown Limitations: Looker's markdown implementation may not support all markdown features, so using HTML is often more flexible for advanced formatting.
Testing and Debugging:
After saving the dashboard, view it in "View" mode to ensure the image renders correctly.
If the image does not load, check the URL in a browser to confirm it is valid and accessible. Look for errors in the browser's developer console (e.g., 404 Not Found, CORS issues, etc.).
By following these steps, you can successfully add an image to a Looker dashboard using markdown or HTML in a text tile.
height: auto
object-fit: cover: Ensures the image fills the container while maintaining its aspect ratio, cropping as needed.
object-position: top: Aligns the image so that the top portion is visible (this is what ensures the upper 50% is shown).
Adjusting the Crop:
If you know the exact height of the original image, you can set the <div> height to exactly 50% of that value. For example, if the original image is 400px tall, set height: 200px on the <div> to show the upper 50%.
If the image height is dynamic or unknown, you can use relative units (e.g., percentages) or JavaScript (though Looker text tiles do not support JavaScript, so you'd need to estimate or use a fixed height).
Example with a Specific Image Height:
If your image is 400px tall and you want to show the upper 50%, use:
Image Accessibility: Ensure the image URL is publicly accessible, as private or authenticated images may not render in the dashboard.
Testing: After adding the code to the text tile, save the dashboard and view it to ensure the image is cropped as expected. Use the browser's developer tools to inspect the image and adjust the CSS if needed.
Dynamic Images: If you need to crop dynamic images (e.g., based on data), you would need to use LookML to create a dimension or measure (as described in earlier responses) and then use a visualization tile, not a text tile. However, cropping in visualization tiles is not natively supported, so you might need to preprocess the images outside of Looker.
By following these steps, you can display only the upper 50% of an image in a Looker dashboard text tile using HTML and CSS.