Feature #18593
closedApproach for fully scalable layouts: relative img dimensions using em
0%
Description
If you try to realize a fully scalable layout with TYPO3, you will soon recognize, that your images won't scale (though the rest of your layout might, if done completely with em units).
This is due to img params being always set based on unit px by css_styled_content+TYPO3 (I'm talking of content images, respectively those images which are passed through tslib_cObj->cImage()).
The following patch implements an approach to make this configurable for css_styled_content.
To enable it for normal content elements and css_styled_content, you need at least
tt_content.image.20.useEM = 1 (default value = 0)
and will f.e. get instead of (I'm omitting the brackets, since they won't show in bugtracker)
img src="..." width="10" height="10"
the corresponding values using the unit em like
img src="..." style="width:0.1em;height:0.1em"
for all tt_content images - and they will scale from now on by changing the font size.
This of course can be used as you just need it - f.e. by not redefining the tt_content.image TS but the according part of "your" styles.content.get ...
Furthermore, there's the property useEM.scaleFactor (default value set to 0.1), which is used when useEM = 1 and then defines the scaling factor for calculating the em unit from the original size of the image in px.
useEM.scaleFactor = 0.1
The following podcast with Thomas Biller demonstrates what a "fully scalable" layout could mean (he doesn't start with that topic, you'll have to watch the whole thing...) :
http://castor.t3o.punkt.de/files/podkast_7mf_css.m4v
(issue imported from #M8070)
Files
Updated by Ralf Hettinger over 16 years ago
Forgot to mention:
You'll have to adapt or redefine the css coming from css_styled_content which can be found in typo3/sysext/css_styled_content/static/setup.txt at the plugin.tx_cssstyledcontent._CSS_DEFAULT_STYLE part. The css still uses px values - which can't be changed automatically, since it's up to you where the useEM feature is applied and therefore where em values would be more appropriate.
Furthermore, you very probably want to get rid of the border="..." attribute for images that are outputted with useEM=1 by setting the not to well known property disableImgBorderAttr = 1 as well.
Updated by Ralf Hettinger over 16 years ago
Unfortunately, I introduced a bug by a typo... please use _v2
Updated by Mario Rimann almost 16 years ago
I changed the patch a little (replaced $imgSF with $scaleFactor) in order to make code more readeable. The patch applied to my TYPO3 4.2.3 without problems - test successful.
Updated by Mario Rimann almost 16 years ago
Patch is pending in core list now (RFC). Hope this finds it's way into the trunk!
Updated by Dmitry Dulepov almost 16 years ago
If I have a 450x300px image, I usually scale it to 150x100 for thumbnails. How do I scale it with this patch?
Updated by Steffen Kamper almost 16 years ago
@Dmitry Dulepov - you don't need to change anything, the thumbnail generation will work with px.
The only change is the output in HTML where the unit is written in em. For proper render you need to configure the scalefactor, and this depends on your CSS definition.
Updated by Franz Koch almost 16 years ago
Could anybody please tell me a usecase for scaling images with em or some accessibility guidelines or whatever? I'm quite interested in accessibility, but haven't found anything about this on the EfA-Website ("einfach-fuer-alle.de" - German Website about accessibility guidelines). Is it even necessary for better accessibility? Modern browsers also scale images and layouts with fixed pixel dimensions and disabled persons will have a magnifier tool anyway - so I wonder what the intention behind this is. I use relative font-sizes for years now - but never heard from images with dimensions in "em".
Thanks.
Updated by Ralf Hettinger almost 16 years ago
Franz-Xaver, you may want to have a look at [1] - I would think it may be interpretation for the same said there being just right for images as well regarding accessibility. The topic is discussed at [2] as well (and certainly at much more places). And you may interpret [3] as an official guideline, considering the german standard BITV.
I personally would think it comes down to the following (as modern browsers being able to achieve this as well, as you've already mentioned): Does the visitor need to know his browser capabilities - or is it maybe a better idea to have another possibility to scale a site by using some buttons available as part of the website's interface itself. Point of view I think.
Finally, you may want to try the example at [4] by using the button "+" at the top right of the page (which is a bit hidden admittedly) to get a visual experience of what the intention of this feature here is... ;)
--
[1] http://www.einfach-fuer-alle.de/artikel/10tipps/ (issue 4)
[2] http://www.einfach-fuer-alle.de/blog/id/2232/
[3] http://www.einfach-fuer-alle.de/artikel/bitv/anlage-1/ (issue 3.4)
[4] http://www.ea-aw.de/en/service/film-and-photographs/photographs-of-10th-anniversary.html
Updated by Fernando Arconada over 15 years ago
Is this patch really finished? or are there issues opened?
Updated by Ralf Hettinger over 15 years ago
It is finished for the feature it describes "as is". Which means that you can use it for outputting images with em units.
There are further approaches and ideas being discussed at the content rendering mailing list [1], which are not covered by this patch but would be very useful as well.
[1] http://lists.netfielders.de/pipermail/typo3-project-content-rendering/2008-December/001164.html
Updated by Jochen Rieger about 15 years ago
Wow ... I was looking for this one for months now! You really need this for fully scalable websites (in FF < 3 and IE 6).
Has anybody got a working patch for 4.2.8?
I tried the one for 4.2.3 but it failed.
Updated by Ralf Hettinger about 15 years ago
Hey Jochen, glad you like it.
I'll provide a patch for 4.2.8 and trunk this week... and not to forget Safari 2 in the list of old style browsers ;)
Updated by Jochen Rieger about 15 years ago
Hi Ralf,
that would be tremendous!
We always only removed the width and height attribs in cImage()... but this will only do good if you have fixed width's of images in the content area... so you can set up an EM width in your stylesheet.
From what I could see in the patch file, yours is really fitting all needs and is flexible as should be!
Thanks in advance! :)
Updated by Ralf Hettinger about 15 years ago
Hi Jochen,
using em imo fulfills the requirement of a fully scalable layout.
For "partial" scalability an approach using % would be more useful, I suppose... this would be the next step and even interesting for modern browsers, too.
=> is a topic discussed in the Content Rendering list
Updated by Ralf Hettinger about 15 years ago
Uploaded patch against 4.2.8
- code cleanup to be CGL compliant.
- Added feature named omitDimensionParams = [0,1],
which just enables you to turn off the output of style="width:...; height:...;" within <img>-tags when generating these tags by TYPO3's tslib_cObj->cImage method.
Note: the patch against 4.2.3 did apply for 4.2.8 with some offset, but properly working. You may want to use something like
$ patch -p0 < 0008070_4.2.8.patch
from within your TYPO3 installation directory and the patch file itself stored in this directory as well.
Updated by Jochen Rieger about 15 years ago
Hi Ralf,
great (also that new feature!)... unfortunately the patch seems not to apply properly in my 4.2.8 ... here's the output:
$ patch -p0 < 0008070_4.2.8.patch
patching file typo3/sysext/cms/tslib/class.tslib_content.php
Hunk #1 FAILED at 2654.
1 out of 1 hunk FAILED -- saving rejects to file typo3/sysext/cms/tslib/class.tslib_content.php.rej
patching file typo3/sysext/css_styled_content/pi1/class.tx_cssstyledcontent_pi1.php
Hunk #1 FAILED at 403.
Hunk #2 FAILED at 643.
Hunk #3 FAILED at 668.
Hunk #4 FAILED at 737.
Hunk #5 FAILED at 764.
Hunk #6 FAILED at 833.
6 out of 6 hunks FAILED -- saving rejects to file typo3/sysext/css_styled_content/pi1/class.tx_cssstyledcontent_pi1.php.rej
patching file typo3/sysext/css_styled_content/static/setup.txt
Hunk #1 FAILED at 1318.
Hunk #2 FAILED at 1353.
Hunk #3 FAILED at 1374.
Hunk #4 FAILED at 1550.
4 out of 4 hunks FAILED -- saving rejects to file typo3/sysext/css_styled_content/static/setup.txt.rej
Updated by Ralf Hettinger about 15 years ago
Jochen, I just counter checked with a fresh dl of 4.2.8 from sourceforge.
The patchfile works without any flaws for me; you may have an already patched core?
Updated by Jochen Rieger about 15 years ago
Strange ... too make sure that it's not a patched one I even downloaded a fresh source from typo3.org / sourceforge.
I testet it now as well on my mac ... test before was on Debian Lenny. Both have the same output concerning the failing hunks.
Maybe YOU had a patched 4.2.8 that you made the patch against?! :)
Really strange. I did exactly as you described (which is the usual way for me to patch T3 sources anyway).
Hmmm ... maybe you could check, if it really was an original 4.2.8 that you made the patched against... if so, I'll go ahead and try to apply the changes manually. I'd then repost a patch for comparison.
Updated by Ralf Hettinger about 15 years ago
Jochen, that is indeed strange.
Patch was created on a Debian Lenny against a fresh dl from sf... and counter checked there as well.
You're not lacking write permissions or anything of the like? Well, I suppose you would have gotten other error messages then... sorry, I have no idea what is wrong there.
Updated by Jochen Rieger about 15 years ago
Hi Ralf,
don't worry ... thanks anyway. As stated I might find the time to patch it manually and then do a diff that I will compare to yours... maybe then we can find out what the issue might be.
Thanks for your efforts!
Updated by Fernando Arconada about 15 years ago
please if you like that patch vote in the maillist
Updated by Alexander Opitz about 11 years ago
- Status changed from New to Needs Feedback
- Target version deleted (
0) - TYPO3 Version set to 4.2
Hi,
as this issue is very old. Does the problem still exists within newer versions of TYPO3 CMS (4.5 or 6.1)?
Updated by Jochen Rieger about 11 years ago
Hi Alexander,
I think with 6.2 and the ability to render responsive images, it should not be an issue anymore - but I have not checked that in full depth.
But I did have a close look at 6.1.5 right now. Although we have nicely separated Content Objects now in the sysext "frontend", the ImageContentObject still calls $this->cObj->cImage(...). And in that function width and height both are included in the IMG tag in fully hardcoded manner.
Updated by Alexander Opitz about 11 years ago
- Status changed from Needs Feedback to New
Ok, understand, I think such thing wasn't fixed for 6.2 so leave this open.
Updated by Georg Ringer almost 10 years ago
- Status changed from New to Resolved
Width and height can be removed from the img template. Therefore resolved in 6.2