Project

General

Profile

Actions

Bug #60415

closed

Importing images from pages media field fails if filepath contains whitespaces

Added by Sven Tappert over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2014-07-20
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

lib.slideshow = FILES
  stdWrap.wrap = <div class="slideshow">|</div>

  references {
    table = pages
    uid.data = page:uid
    fieldName = media
  }

  renderObj = IMAGE
  renderObj {
    file.import.data = file:current:publicUrl
    altText.data = file:current:title // page:title
  }
}
Actions #1

Updated by Sven Tappert over 9 years ago

The above TS setup works perfect until 6.1. Since 6.2 the publicUrl function in \Core\Resource\Driver\LocalDriver::getPublicUrl() encodes the file name with rawurlencode().

This might be intended, but if the file name or path contains whitespaces, the image file will not be rendered, because the encoded filepath cannot be found in the filesystem:

In \TYPO3\CMS\Core\Resource\ResourceFactory::retrieveFileOrFolderObject() the file cannot be found ($input holds the rawurlencoded filepath for the given TS setup).

// e.g. $input = 'fileadmin/user_upload/filename%20with%20whitespaces.jpg'
$input = \TYPO3\CMS\Core\Utility\PathUtility::getCanonicalPath(ltrim($input, '/'));
if (@is_file(PATH_site . $input)) {
    // only the local file
    return $this->getFileObjectFromCombinedIdentifier($input);
}

It's not clear to me, if getCanonicalPath() should remove the urlencoding, if the encoding should be removed inbetween or if LocalDriver::getPublicUrl() should not encode the url at all.

I also proposed to use this alternative TS setup:

file.import.data = file:current:localPath

Unfortunately this will create a temporary file with ugly filename instead of using the original file (e.g. "typo3temp/fal-tempfile-wHoMB2.jpg"), which is absolutely unacceptable with regard to ranking optimized filenames.

Actions #2

Updated by Markus Klein over 9 years ago

Why are you handing in the path all? If you have the file object, you can simply use the uid. That should work easily.

file.import.data = file:current:uid
file.treatIdAsReference = 1

Example taken from css_styled_content

Actions #3

Updated by Markus Klein over 9 years ago

  • Status changed from New to Needs Feedback
Actions #4

Updated by Sven Tappert over 9 years ago

Thank you for your quick reply Markus! I stumbled about it in css_styled_content in the meantime and this solution works perfectly. However all sample snippets I've seen before were using the publicUrl code.

Actions #5

Updated by Markus Klein over 9 years ago

  • Status changed from Needs Feedback to Closed

Well, these samples are not official samples I hope. ;-)

Actions

Also available in: Atom PDF