Skip to content
Console

Styles

A Style saves a set of CoreIX processing parameters under a name, so at access time you write only the name. Use it to standardize thumbnail specs across your site and to hide processing parameters. It is also a prerequisite for original file protection.

To get there, go to Object Storage (对象存储) › Bucket list (桶列表) › click the bucket name › Media processing (媒体处理) › Style rules (Style规则).

Create a style

Create a rule

Click New rule (新建规则).

Enter a name and code

Enter thumb for Rule name (规则名称) and w=500&h=500&fmt=webp for Code (代码).

Preview

Click Refresh preview (刷新预览) to see the effect on a sample image.

Save

Click Save (保存), and it takes effect immediately.

Rule nametextRequired

1 ~ 36 characters, digits and upper- and lowercase letters only, case-sensitive. Names must be unique within a bucket. A duplicate shows "您已添加该条规则,请更换规则名称" (you have already added this rule; please change the rule name).

CodetextRequired

The processing parameters, written the same way as URL parameters, joined with &, without a leading ?, up to 1000 characters. Special characters must be URL-encoded, for example % as %25 and # as %23. For the available parameters, see the CoreIX overview.

Parameters aren't validated one by one when you save, so confirm the effect with the preview. You can't create or edit styles while the account has an overdue balance.

Use a style

Append !style:style-name or !style=style-name to the file address. The two forms are equivalent:

https://img.example.com/photos/girl.jpeg!style:thumb
https://img.example.com/photos/girl.jpeg!style=thumb

The style goes in the path and is not a URL parameter. Put other parameters after ? as usual.

When you access with a signed link, sign !style:thumb as part of the object key, for example a key of photos/girl.jpeg!style:thumb.

If the style name doesn't exist, the whole address is treated as a file name and returns 404.

Variable parameters

A * before a parameter name means the value is only a default, which URL parameters can override at access time. Parameters without * are fixed.

Take the style card with the code w=1200&*txt=@Bitiful&*txt-size=0.04 as an example:

AddressActual effect
girl.jpeg!style:cardw=1200, text is @Bitiful
girl.jpeg!style:card?txt=Hellow=1200, text is Hello
girl.jpeg!style:card?txt=Empty value; the default text @Bitiful is still used
girl.jpeg!style:card?w=3000w is fixed and stays 1200
girl.jpeg!style:card?h=100h isn't in the style and is ignored

Summary of the rules:

  • When you use a style, all processing parameters outside the style are ignored.
  • If the same parameter is written both with and without *, the one without * wins.
  • Non-processing parameters, such as the download file name, are unaffected.

Don't make parameters that affect file size (format, width, height, quality, and so on) variable. Otherwise, visitors can generate large numbers of images in different sizes, which increases processing and data transfer costs.

Common styles

NameCodePurpose
thumbw=300&h=300&fmt=autoSquare thumbnail; the format is chosen automatically by browser
previeww=1600&q=80&fmt=autoLarge image for detail pages
avatarw=200&h=200&pos=smartAvatar; automatically keeps faces
coverframe=auto&w=1280Video cover
wmw=2000&txt=@MyBrand&txt-pos=0.95,0.93Add a text watermark

For parameter details, see Resize images, Format conversion, Text watermarks, and Frame capture.

Edit and delete

  • Edit (编辑): Changes to the code take effect immediately. Old images accessed through a CDN are still cached, so you need to purge the cache. If you change the rule name while editing, it is the same as saving a new rule, and the old rule is kept.
  • Delete (删除): Links that use the style become 404. You can't delete a style that is set as the Default Style (默认Style) of original file protection. Change it in original file protection first.

Relationship to original file protection

Creating a style alone does not stop visitors from using parameters such as ?w=3000 directly or accessing the original image. To require visitors to access only through styles, also turn on original file protection.

FAQ

It returns 404 NoSuchKey
  1. The style name's case doesn't match, or the style has been deleted.
  2. !style: was written as a URL parameter.
  3. The original file doesn't exist.
Do styles work on a CDN?

Yes, with the same syntax.

Can I use a style across buckets?

No. Each bucket has its own settings.

It returns TooLargeForCoreIX

The original image exceeds 200 MiB. See Supported formats.