简体   繁体   中英

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)
  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. 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:

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

To scale and possibly crop the image, make use of the height and width parameters of this ViewHelper. The image will then automatically be scaled by TYPO3 and used by the image ViewHelper.

The height and width properties support the modifiers m and c . 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. 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.

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" /> .

Tell us more about your extension and I am sure we will find a way that suits your idea.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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