简体   繁体   English

TYPO3:在自定义扩展名中从BE访问大拇指

[英]TYPO3: Access thumbs from BE in custom extension

This is how I image my custom extension to work: 这是我为自定义扩展程序工作的图像:

  1. Author creates an element for the extension 作者为扩展创建一个元素
  2. He fills in the title, alt and other information and uploads an image 他填写标题,替代和其他信息,然后上传图片
  3. Listview in the Frontend renders a thumbnail of the uploaded image (for each element created in the Backend) 前端中的Listview呈现上传图像的缩略图(针对在后端中创建的每个元素)
  4. Full image is visible in Single view 完整图像在单视图中可见

I actually only need help in the third step. 实际上,我仅在第三步需要帮助。 Since TYPO3 already renders a thumbnail for the Backend, I'd like to access this one to avoid redundant files. 由于TYPO3已经为后端渲染了缩略图,因此我想访问该缩略图以避免冗余文件。 Is there a way to output this file in the listview (Frontend)? 有没有办法在列表视图(前端)中输出此文件?

I hope you guys actually understood what I want. 我希望你们真的了解我想要的。

When rendering the list view in the frontend, you can just render the image property of your domain model, like this: 在前端中呈现列表视图时,您可以仅呈现域模型的image属性,如下所示:

<f:image image="{myObject.image}" alt="..."/>

To scale and possibly crop the image, make use of the height and width parameters of this ViewHelper. 要缩放并可能裁剪图像,请使用此ViewHelper的heightwidth参数。 The image will then automatically be scaled by TYPO3 and used by the image ViewHelper. 然后,图像将由TYPO3自动缩放,并由图像ViewHelper使用。

The height and width properties support the modifiers m and c . heightwidth属性支持修饰符mc The modifier m makes the image fit into the rectangle given by height and width while preserving its aspect ratio, while c makes the image cover the given rectangle while preserving aspect ratio, and crops away the parts of the image overlapping the rectangle. 修饰符m使图像适合高度和宽度指定的矩形,同时保留其长宽比;而c使图像覆盖指定的矩形,同时保留宽高比,并裁剪掉与矩形重叠的图像部分。 Here are more details about these modifiers. 以下是有关这些修饰符的更多详细信息。

Example: 例:

<f:image image="{myObject.image}" alt="..." height="100c" width="100c"/>

This scales the image such that the shortest edge is 100px long, and then cuts out the central part of the image to make 100x100 pixels in size. 这样可以缩放图像,以使最短的边长为100px,然后切出图像的中心部分以形成100x100像素的大小。

To give you sufficient help I think you should tell us more about the requirements of your extension. 为了给您足够的帮助,我认为您应该向我们详细介绍扩展程序的要求。 Is there a database connection? 有数据库连接吗? If yes you could save all the thumbnail paths there and work with a repository. 如果是,则可以将所有缩略图路径保存在那里并使用存储库。 Afterwards it would be possible to forward this thumbnail path to the frontend (list view) and render it with <f:image src="{thumbnailPath}" alt="landschaft" /> . 之后,可以将此缩略图路径转发到前端(列表视图),并使用<f:image src="{thumbnailPath}" alt="landschaft" />渲染。

Tell us more about your extension and I am sure we will find a way that suits your idea. 告诉我们更多关于您的扩展名的信息,我相信我们会找到适合您想法的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM