helsingborg-stad / acf-select-image-field
1.4.5
2024-08-23 11:07 UTC
- dev-main
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.4
- 1.3.3
- 1.3.1
- 1.3.0
- 1.2.5
- 1.2.2
- 1.2.0
- 1.1.4
- 1.1.1
- 1.1.0
- 1.0.3
- 1.0.0
- dev-chore/adding-listing-image
- dev-fix/image-select-default-value-first
- dev-fix/only-target-image-select-field
- dev-feature/block-conditions
- dev-feature/mutation-and-field-specific-conditions
- dev-fix/remove-disabled-for-all-children
- dev-feature/adding-segment-svg
- dev-fix/styling-fixes
- dev-chore/removing-unused
- dev-feature/conditions-for-custom-field-type
This package is auto-updated.
Last update: 2024-08-23 11:08:03 UTC
README
ACF 图像选择 MU (必须使用) 插件是 Advanced Custom Fields (ACF) 的自定义字段类型,允许您使用带有图像作为选项的单选按钮。这使得在 WordPress 项目中创建视觉吸引力和用户友好的选择变得容易。
安装
- 下载最新版本。
- 将
acf-image-select
文件夹上传到您的 WordPressmu-plugins
目录(通常是wp-content/mu-plugins
)。如果mu-plugins
目录不存在,您可以创建它。 - 当放置在
mu-plugins
目录中时,该插件将自动作为 MU 插件激活。
使用
一旦 ACF 图像选择 MU 插件激活,您就可以在 ACF 字段组中使用新字段类型。以下是设置方法:
- 在 ACF 设置中创建或编辑字段组。
- 添加新字段并选择“图像选择”作为字段类型。
- 使用标签(在文章后端可见)和值(图像的名称以及后端字段的实际值)配置字段设置。
- 将字段组添加到您的文章、页面或自定义文章类型中。
自定义
要添加自己的图像
- 将您的 svg 文件上传到 assets 文件夹。文件名现在将在字段设置中可用。它也将自动成为字段的值。
限制
正常条件(基本) ACF 图像选择插件在条件逻辑方面有以下限制
-
它支持“与”或“或”条件,但不支持两者。
支持的条件
- "image select" != "condition1" AND "image select" != "condition2"
- "image select" == "condition1" OR "image select" == "condition2"
不支持的条件
- "image select" != "condition1" OR "image select" != "condition2" AND "image select" != "condition3"
此解决方案将允许基本的条件逻辑,在大多数情况下都能正常工作。
使用 ACF 条件(高级)
- 在创建图像选择字段时,同时创建一个具有相同名称的“隐藏”字段,如 "{my_field_name}_conditional"。
- 将条件设置到该字段而不是图像选择。
- 每次图像选择字段更改时,它将更新此字段的值,并像默认的 ACF 条件一样工作。
在实现 ACF 图像选择字段的条件逻辑时,请牢记这些限制。