question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Background color support for images

See original GitHub issue

Implementation status

  • TypeScript (available with the Outlook container in the visualizer)
  • UWP (#1412)
  • .NET (#1415)
  • iOS (#1414)
  • Android (#1413)
  • Documentation

Problem

Often, it is necessary to present one single image on top of a variety of different background colors. It is in general not practical to either have to dynamically generate the appropriate image server-side or to have to store all possible combinations somewhere.

Solution

Add a backgroundColor property to the Image element. With that, a card author can lay an image with a transparent background on top of any color they want. The background color respects the image’s style, e.g. when set to “person”, which crops the image to a circle, the background color is clipped to the circle.

Example:

{
	"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
	"type": "AdaptiveCard",
	"version": "1.0",
	"body": [
	    {
	        "type": "Image",
	        "size": "medium",
	        "url": "http://messagecardplayground.azurewebsites.net/assets/circleontransparentbackground.png",
	        "backgroundColor": "#CCCCCC"
	    },
	    {
	        "type": "Image",
	        "size": "medium",
	        "url": "http://messagecardplayground.azurewebsites.net/assets/circleontransparentbackground.png",
	        "backgroundColor": "#DDDDDD",
	        "style": "person"
	    }
	]
}

The above payload renders the same image on two different colors using the both supported image styles: image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
andrewleadercommented, Jun 21, 2018

Did we think about accessibility for this?

For images, we have ideas in place for how we could append query strings to request high contrast versions of the image, allowing the author to provide a different image for high contrast… but we currently don’t have a way to allow the author to provide a different background color for high contrast.

I suppose the backgroundColor property could also be an object that includes “normal” and “highContrast” colors?

I’ll add this to the accessibility bucket list.

0reactions
paulcam206commented, Sep 24, 2018

Documentation is done and in the mahiding/site1.1 branch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

background-image - CSS: Cascading Style Sheets | MDN
The background-image CSS property sets one or more background images on an element.
Read more >
CSS: background image on background color
I set the panel to blue with the css background: #6DB3F2; and the background image with background-image: url('images/checked.png') . But it ...
Read more >
Change Background Color of Photo Online in 1 Click
With Fotor's free online background color changer, you can change background color of photo to white, blue, black and any other color in...
Read more >
CSS background-image property
The background-image property sets one or more background images for an element. By default, a background-image is placed at the top-left corner of...
Read more >
Tinted Images with Multiple Backgrounds
Tinted Images with Multiple Backgrounds ... The background property in CSS can accept comma separated values. “Multiple” backgrounds, if you will.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found