How can I create a Consumer and set the default image styles provided programatically?

Created on 3 March 2023, about 2 years ago
Updated 17 March 2023, about 2 years ago

Problem/Motivation

I run some Playwright tests on a CI server which initializes my database and content from scratch.

I create a Consumer programmatically, but the problem is that since no image styles are selected by default, it doesn't return anything and the tests fail.

How can I set the image styles when programmatically creating a consumer?

Steps to reproduce

I create the consumer like this:

$consumer = Consumer::create([
  'label' => 'JSON:API Images',
  'description' => "My consumer",
  'client_id' => 'my_sepcial_consumer',
  // @todo This can't be set like this.
  // 'image_styles_target_id' => ['fallback_phone', 'phone'],.
  'is_default' => TRUE,
  'third_party' => FALSE,
]
);
💬 Support request
Status

Fixed

Version

4.0

Component

Documentation

Created by

🇯🇵Japan ptmkenny

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024