欢迎 What's new in Chrome extensions Get help with Chrome extensions API reference Samples
欢迎 What's new in Chrome extensions Get help with Chrome extensions API reference Samples

chrome.wallpaper

  • Description

    Use the chrome.wallpaper API to change the ChromeOS wallpaper.

  • Permissions
    wallpaper
  • Availability
    Chrome 43+

Manifest

You must declare the "wallpaper" permission in the app's manifest to use the wallpaper API. For example:

{
"name": "My extension",
...
"permissions": [
"wallpaper"
],
...
}

Examples

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() {}
);

Summary

Types

WallpaperLayout

Chrome 44+

The supported wallpaper layouts.

Type

"STRETCH"

,

"CENTER"

,
or

"CENTER_CROPPED"

Methods

setWallpaper

chrome.wallpaper.setWallpaper(
  details: object,
  callback?: function,
)
Promise

Sets wallpaper to the image at url or wallpaperData with the specified layout

Parameters

  • details

    object

    • data

      ArrayBuffer optional

      The jpeg or png encoded wallpaper image as an ArrayBuffer.

    • filename

      string

      The file name of the saved wallpaper.

    • The supported wallpaper layouts.

    • thumbnail

      boolean optional

      True if a 128x60 thumbnail should be generated. Layout and ratio are not supported yet.

    • url

      string optional

      The URL of the wallpaper to be set (can be relative).

  • callback

    function optional

    The callback parameter looks like: (thumbnail?: ArrayBuffer) => void

    • thumbnail

      ArrayBuffer optional

      The jpeg encoded wallpaper thumbnail. It is generated by resizing the wallpaper to 128x60.

Returns

  • Promise<ArrayBuffer | undefined>

    Chrome 96+

    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.

We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.