wordpress - 如何使用 Timber/Twig 从 ACF 选项页面图像中显示缩略图
问题描述
我正在开发一个自定义 WordPress 主题,并且很难从 ACF(高级自定义字段)选项页面字段中将缩略图图像显示在我的页面上,我在 WordPress 中使用了木材/树枝,并尝试了多种方法但均未成功:
{{options.tool_agreement.url }}
并且{{options.tool_agreement('thumbnail') }}
还有{{options.tool_agreement.thumbnail }}
而且{{options.tool_agreement('thumbnail').url }}
这些都不适合我??
〜感谢任何提示!
这是转储的示例:{{dump(options.tool_agreement)}}
array (size=24)
'ID' => int 254
'id' => int 254
'title' => string 'sample-agreement' (length=16)
'filename' => string 'sample-agreement.jpg' (length=20)
'filesize' => int 54741
'url' => string 'https://protoolsite.local/wp-content/uploads/2021/07/sample-agreement.jpg' (length=78)
'link' => string 'https://protoolsite.local/sample-agreement/' (length=48)
'alt' => string '' (length=0)
'author' => string '1' (length=1)
'description' => string '' (length=0)
'caption' => string '' (length=0)
'name' => string 'sample-agreement' (length=16)
'status' => string 'inherit' (length=7)
'uploaded_to' => int 0
'date' => string '2021-07-02 00:27:42' (length=19)
'modified' => string '2021-07-02 00:27:42' (length=19)
'menu_order' => int 0
'mime_type' => string 'image/jpeg' (length=10)
'type' => string 'image' (length=5)
'subtype' => string 'jpeg' (length=4)
'icon' => string 'https://protoolsite.local/wp-includes/images/media/default.png' (length=67)
'width' => int 544
'height' => int 703
'sizes' =>
array (size=18)
'thumbnail' => string 'https://protoolsite.local/wp-content/uploads/2021/07/sample-agreement-150x150.jpg' (length=86)
'thumbnail-width' => int 150
'thumbnail-height' => int 150
'medium' => string 'https://protoolsite.local/wp-content/uploads/2021/07/sample-agreement-232x300.jpg' (length=86)
'medium-width' => int 232
'medium-height' => int 300
'medium_large' => string 'https://protoolsite.local/wp-content/uploads/2021/07/sample-agreement.jpg' (length=78)
'medium_large-width' => int 544
'medium_large-height' => int 703
'large' => string 'https://protoolsite.local/wp-content/uploads/2021/07/sample-agreement.jpg' (length=78)
'large-width' => int 544
'large-height' => int 703
'1536x1536' => string 'https://protoolsite.local/wp-content/uploads/2021/07/sample-agreement.jpg' (length=78)
'1536x1536-width' => int 544
'1536x1536-height' => int 703
'2048x2048' => string 'https://protoolsite.local/wp-content/uploads/2021/07/sample-agreement.jpg' (length=78)
'2048x2048-width' => int 544
'2048x2048-height' => int 703
解决方案
推荐阅读
- python - 用星号屏蔽 SSN 的前五位数字
- c - 在 C 中创建字符串并将其传递给函数的最佳方法是什么?
- python - 尽管存在 Mac,Python pandas read_csv 返回 FileNotFoundError
- sql - postgresql - 将类似查询“分组”为子查询
- ember.js - 为什么 Ember Octane 中的跟踪阵列不会更新?
- codeigniter-3 - 如何从库类中调用辅助函数
- python - Folium Search Plugin 没有 FeatureGroup 的结果
- ruby-on-rails - 关联模型的表单对象中的 NoMethodError
- perl - 需要帮助了解 Perl 5 如何解析引用相同变量的复合赋值语句
- php - Laravel 5 在服务器上显示空白页面但在本地工作