首页 > 解决方案 > Cloudinary - 在图像上传小部件中将叠加文本添加到 thumbnailTransformation

问题描述

我正在使用上传图像小部件,我想添加文本叠加但不知道如何,有人可以回答我吗?

thumbnailTransformation: [{ width: 300, height: 300, crop: 'fill', border: "2px_solid_red" }],

标签: cloudinary

解决方案


您需要包含一个overlay带有覆盖参数的对象的键,在这种情况下,是特定于文本的。

例如 -

thumbnailTransformation: [
  {
    width: 300,
    height: 300,
    crop: 'fill',
    border: "2px_solid_red"
  },
  {
    overlay: {
      font_family: "Arial",
      font_size: 20,
      text: "Test"
    },
    gravity: "north_east"
  }
]

以下是您可以尝试的 JSFiddle:https ://jsfiddle.net/rhdvgy19/

所有其他可用的文本样式选项都可以在这里找到 - https://cloudinary.com/documentation/image_transformations#styling_parameters


推荐阅读