Bug #54772

Image width and height has no effect

Added by König David over 5 years ago. Updated almost 4 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
Start date:
2014-01-06
Due date:
% Done:

100%

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

Description

In the Fluid 6.2.0 ImageViewHelper width and height have no effect:

<f:image src="{image.uid}" alt="" maxWidth="150" maxHeight="150" width="150" height="150" treatIdAsReference="1" />
<f:image src="path/to/an/image800x800.jpg" alt="" maxWidth="150" maxHeight="150" width="150" height="150" />

both generate this Output:

<img src="path/to/an/image800x800.jpg" width="800" height="800" alt="">

This Bug occurs since version 6.2 beta2 (not in beta1)

Screenshot-1.png View - Screenshot-1 (910 KB) Philipp Müller, 2015-06-17 09:05


Related issues

Related to TYPO3 Core - Bug #71576: Image Processing broken Closed 2015-11-14

Associated revisions

Revision 97c0da20 (diff)
Added by Claus Due almost 4 years ago

[BUGFIX] Fallback to argument values in f:image/f:media on invalid dimensions

  • Check which width/height to use; the ones from arguments or the
    ones returned after image scaling (uses original if different).
  • Do not apply the "width" and "height" attributes if resolved
    dimensions are empty.

The effect is that if the ViewHelper is used with dimensions on a
site that does NOT support image resizing, rather than output an
invalid tag (with width/height being zero or full size of image)
it now outputs a tag where width/height is set to the (numeric part
of the) value of the width/height arguments.

Long story short: if the server can't scale images the browser can.

Change-Id: I8bcaa5954a7f71d16656b85789b6d7d63298a0d8
Resolves: #54772
Resolves: #40254
Releases: master
Reviewed-on: https://review.typo3.org/44138
Reviewed-by: Stefan Neufeind <>
Reviewed-by: Daniel Goerz <>
Reviewed-by: Mathias Schreiber <>
Tested-by: Mathias Schreiber <>
Tested-by: Daniel Goerz <>
Reviewed-by: Oliver Eglseder <>
Tested-by: Oliver Eglseder <>
Reviewed-by: Steffen Müller <>
Reviewed-by: Morton Jonuschat <>
Tested-by: Morton Jonuschat <>

History

#1 Updated by Nadine Schwingler over 5 years ago

  • % Done changed from 0 to 10

I've got the same problem.

I made a quick and dirty fix in the TYPO3\CMS\Fluid\ViewHelpers\ImageViewHelper

replace
$this->tag->addAttribute('height', $processedImage->getProperty('height'));
$this->tag->addAttribute('width', $processedImage->getProperty('width'));

with
if ($height > 0) $this->tag->addAttribute('height', $height);
else $this->tag->addAttribute('height', $processedImage->getProperty('height'));
if ($width > 0) $this->tag->addAttribute('width', $width);
else $this->tag->addAttribute('width', $processedImage->getProperty('width'));

#2 Updated by Thorsten G. about 5 years ago

UPDATE sys_file_metadata
INNER JOIN sys_file ON sys_file.uid = sys_file_metadata.file
SET sys_file_metadata.width = sys_file.zzz_deleted_width, sys_file_metadata.height = sys_file.zzz_deleted_height
WHERE sys_file_metadata.width = 0 AND sys_file.mime_type LIKE 'image/%'

#3 Updated by Alexander Opitz about 5 years ago

  • Status changed from New to Needs Feedback

Hi,

was this issue fixed or does it still exists?

#4 Updated by Martin Eberle almost 5 years ago

this bug is still there in TYPO3 6.2.5 :(

#5 Updated by Alexander Opitz almost 5 years ago

  • Project changed from Fluid to TYPO3 Core
  • Category changed from Fluid: ViewHelpers to Fluid
  • Status changed from Needs Feedback to New
  • % Done changed from 10 to 0
  • TYPO3 Version set to 6.2
  • Is Regression set to No

#6 Updated by Dominik Hahn over 4 years ago

We are still having those issues in the newly released TYPO3 CMS 6.2.12

#7 Updated by Carsten Tornow over 4 years ago

I have the same problem!
TYPO3 v. 6.2.12

#8 Updated by Philipp Müller over 4 years ago

I've the same problem with TYPO3 6.2.13.

Code:

tt_content.image.20.stdWrap.override {
  cObject = COA
  cObject {
    10 = FILES
    10 {
      references {
        table = tt_content
        uid.field = uid
        fieldName = image
      }

      renderObj = IMAGE
      renderObj {
        file {
          import.data = file:current:publicUrl
          width = 154c
          height = 154c
        }
        stdWrap {
          typolink.parameter.data = file:current:publicUrl
          typolink.ATagParams = class="fancybox" rel="fancybox{field:uid}" 
          typolink.ATagParams.insertData = 1
          wrap = <div class="img">|</div>
        }
      }
    }
    wrap = <div class="images-overview">|<div class="clear"><!-- --></div></div>
  }

  if.value.field = layout
  if.equals = 1
}

Output:
Screenshot-1

#9 Updated by König David about 4 years ago

  • Target version set to 6.2.14

We have nearly a same issue.

We use TemplaVoila with dhbw_fal_templavoila

There is the field "field_pdf" where you can link a PDF-file, the other field is "field_pdfpreview", witch generate a preview image in frontend (configuration below.)

The Output generated in default language is:
<img src="fileadmin/_processed_/csm_myPDF_DE_f2d4554718.gif" width="164" height="188" class="imageborder" alt="alt text DE">

and in a other Language:

<img src="fileadmin/user_upload/path/to/myPDF_FR.pdf" width="0" height="0" class="imageborder" alt="alt text FR">

Code:

lib.field_pdfpreview.21 = FILES
lib.field_pdfpreview.21 {
references {
table = tt_content
uid.cObject = COA
uid.cObject {
10 = TEXT
10 {
data = register:tx_templavoila_pi1.parentRec.uid
if.isTrue.data = register:tx_templavoila_pi1.parentRec._LOCALIZED_UID
if.negate = 1
}

20 = TEXT
20 {
data = register:tx_templavoila_pi1.parentRec._LOCALIZED_UID
if.isTrue.data = register:tx_templavoila_pi1.parentRec._LOCALIZED_UID
}
}
fieldName = field_pdf
}
renderObj = COA
renderObj {
10 = IMAGE
10 {
file {
treatIdAsReference = 1
import.data = file:current:uid
maxW = 164
}
altText.field = field_caption
titleText.data = file:current:title
params = class="imageborder"
}
}
}

#10 Updated by Alexander Opitz about 4 years ago

  • Target version changed from 6.2.14 to 6.2.15

#11 Updated by Alexander Opitz about 4 years ago

  • Target version changed from 6.2.15 to 6.2.16

#12 Updated by Claus Due almost 4 years ago

Just a tiny update from the side lines: this issue has been reviewed, judging if it has any impact on or is affected by the merging of the standalone Fluid package as TYPO3 dependency.

Verdict: NOT AFFECTED, NOT SOLVED. Should be implemented pretty much as Nadine describes above - however, there's one pitfall: the "height" and "width" variables should also be checked if they are numeric; or they should be somehow sanitised to remove the "c" or "m" markers. And maybe some special attention on what happens if only one of the dimensions are provided.

#13 Updated by Gerrit Code Review almost 4 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/44138

#14 Updated by Gerrit Code Review almost 4 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/44138

#15 Updated by Gerrit Code Review almost 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/44138

#16 Updated by Gerrit Code Review almost 4 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/44138

#17 Updated by Gerrit Code Review almost 4 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/44138

#18 Updated by Gerrit Code Review almost 4 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/44138

#19 Updated by Gerrit Code Review almost 4 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/44138

#20 Updated by Anonymous almost 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#21 Updated by Morton Jonuschat almost 4 years ago

  • Status changed from Resolved to Rejected

This issue is not easily solvable if the image processing is disable/broken as there are many edge cases where the browser is not able to scale the same way as image processing does.
This issue won't be fixed for now in the core.

Also available in: Atom PDF