1

I am trying to use page content images in typo3 pages. I have uploaded 2 images and in DB only the filenames are stored.

OK - I found the images in uploads direcory! But now how I have to display the image?!

I can hrdcode the upload dir url and add the filename from db, but It's realy ugly and not flexible.

I tryed to use <f:image /> but no chance since it's expecting a resource path?! OK - I found the resource dir but I can't upload images there from the standart typo3 page in cms.

The <f:image /> is realy usefull for me because I need to display images in different sizes and crop them. This all is implemented in the ViewHelper, but I can not tell the ViewHelper to take my image in upload dir.

Please help me how to use the images on pages. The menu for uploading images on page contrent is realy usefull in backend, but I can not display the result in frontend.

2 Answers 2

1

In case, the upload directory is set in the TCA columns config (uploadfolder), you can write your own viewHelper and get the upload directory e.g.

/**
 * @param Tx_(extkey)_Domain_Model_(entity class) $entity 
 * @return string rendered image tags
 */
public function render($entity) {

    $html = '';

    $GLOBALS['TSFE']->includeTCA();
    $uploadfolder = $GLOBALS['TCA']['tx_(extkey)_domain_model_(entity class)']['columns']['(column_name)']['config']['uploadfolder'];

    $images = explode(',', $entity->getImages());

    foreach ($images as $image) {
        $html .= $this->getImageTag($uploadfolder, $image, $width);
    }

    return $html;
}

Have a look at the Tx_Fluid_ViewHelpers_ImageViewHelper class (especially the render method) for code to format your image tags.

1

try using something like this: <f:image src="uploads/tx_extensionname/{object.image}" alt="foo" title="bar" maxHeight="50" />

See the Fluid Wiki Page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.