You must declare the "wallpaper" permission in the app's manifest to use the wallpaper API. For example:
{"name":"My extension",..."permissions":["wallpaper"],...}
For example, to set the wallpaper as the image at https://example.com/a_file.png
, you can call chrome.wallpaper.setWallpaper
this way:
chrome.wallpaper.setWallpaper({'url':'https://example.com/a_file.jpg','layout':'CENTER_CROPPED','filename':'test_wallpaper'},function(){});
The supported wallpaper layouts.
"STRETCH" "CENTER" "CENTER_CROPPED"
chrome.wallpaper.setWallpaper(
details: object,
callback?: function,
)
Sets wallpaper to the image at url or wallpaperData with the specified layout
object
ArrayBuffer optional
The jpeg or png encoded wallpaper image as an ArrayBuffer.
string
The file name of the saved wallpaper.
The supported wallpaper layouts.
boolean optional
True if a 128x60 thumbnail should be generated. Layout and ratio are not supported yet.
string optional
The URL of the wallpaper to be set (can be relative).
function optional
The callback
parameter looks like: (thumbnail?: ArrayBuffer) => void
ArrayBuffer optional
The jpeg encoded wallpaper thumbnail. It is generated by resizing the wallpaper to 128x60.
Promise<ArrayBuffer | undefined>
Promises are supported in Manifest V3 and later, but callbacks are provided for backward compatibility. You cannot use both on the same function call. The promise resolves with the same type that is passed to the callback.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-05-24 UTC.