simonkoehler / fallback
图片回退视图助手
dev-master
2020-07-22 17:25 UTC
Requires
- typo3/cms-core: ^9.5 || ^10.5
Replaces
- simonkoehler/fallback: dev-master
- typo3-ter/fallback: dev-master
This package is auto-updated.
Last update: 2021-12-22 20:49:34 UTC
README
此扩展提供了一个简单的视图助手,用于检查图片是否存在。
我创建它作为我自己的扩展开发的辅助工具,但您也可以将其用于自己的项目,例如,检查自己扩展的字段中的图片路径,并在必要时输出占位符。请参阅使用它的最简单方法
{namespace fallback=SIMONKOEHLER\Fallback\ViewHelpers}
<f:image src="{fallback:image(url:'fileadmin/my-correct-imagepath.jpg')}" maxWidth="800" />
重要提示
此功能仅在您使用 TYPO3 <f:image> 视图助手的 "src" 属性和从 TYPO3 根目录的相对路径时才有效!以下是一个示例。
它做什么?
视图助手检查图片是否存在,然后输出一个占位符。可以使用视图助手属性 "placeholder" 预定义占位符图片,否则将显示由扩展提供的尺寸为 800x600 像素的图片。
安装
您只需要安装此扩展。不需要配置或 TypoScript!
示例用法
{namespace fallback=SIMONKOEHLER\Fallback\ViewHelpers}
<!-- Only the standard placeholder is output here. Also works well as a "helper" for extension development. -->
<f:image src="{fallback:image()}" maxWidth="800" />
<!-- Image not available: The standard placeholder is output here. -->
<f:image src="{fallback:image(url:'fileadmin/my-wrong-imagepath.jpg')}" />
<!-- Image not available with placeholder: The predefined placeholder is output here. -->
<f:image src="{fallback:image(url:'fileadmin/my-wrong-imagepath.jpg', placeholder:'fileadmin/custom-placeholder.jpg')}" />
<!-- Image available with placeholder: Here the image is output as desired. -->
<f:image src="{fallback:image(url:'fileadmin/my-correct-imagepath.jpg', placeholder:'fileadmin/custom-placeholder.jpg')}" />
<!-- Normal usage as a TAG instead of inline: Simply returns the URL -->
<fallback:image url="fileadmin/my-correct-imagepath.jpg" placeholder="fileadmin/custom-placeholder.jpg" />
占位符图片
想报告问题?
https://github.com/koehlersimon/fallback/issues
所有其他请求
联系方式: https://simon-koehler.com/en/contact
你想学习 TYPO3?这是你需要的东西
视频培训 TYPO3 9 LTS(德语) https://www.digistore24.com/redir/246076/GOCHILLA/