自动图像缩放图像或graphicmagick

时间:2011-07-10 18:16:41

标签: imagemagick typo3

我有一个问题取决于imagemagick: 例如,是否可以上传一张尺寸为1200像素高的图片,并根据设备或浏览器的分辨率 - 减少图像的高度 AND 尺寸?

提前致谢

1 个答案:

答案 0 :(得分:2)

您可以根据设备或浏览器版本使用条件。假设你想在下面的图像高度之间切换:

  • 600px for IE6,
  • 320px for mobile devices,
  • 所有其他设备的800px (即普通电脑)

然后将此部分输入模板常量

# for IE6:
[browser = msie] AND [version = 6]
styles.content.imgtext {
        maxH = 600
        maxHInText = 600
}
# for mobile devices:
[useragent = *iPhone*]||[useragent = *iPod*]||[useragent = *Android*]||[useragent = *OperaMini*]||[useragent = *BlackBerry*]
styles.content.imgtext {
        maxH = 320
        maxHInText = 320
}
# For all other browsers
[else]
styles.content.imgtext {
        maxH = 800
        maxHInText = 800
}
[GLOBAL]

模板设置的替代解决方案(如下所述):

# for IE6:
[browser = msie] AND [version = 6]
tt_content.image.20.1.file {
        maxH = 600
        maxHInText = 600
}
# for mobile devices:
[useragent = *iPhone*]||[useragent = *iPod*]||[useragent = *Android*]||[useragent = *OperaMini*]||[useragent = *BlackBerry*]
tt_content.image.20.1.file {
        maxH = 320
        maxHInText = 320
}
# For all other browsers
[else]
tt_content.image.20.1.file {
        maxH = 800
        maxHInText = 800
}
[GLOBAL]
  1. 这些只是条件的一些例子。查看TYPO3 conditions reference了解更多提示。
  2. 如果移动设备的识别无法与useragent一起正常使用,请尝试使用扩展程序cwmobileredirect。它提供了非常可靠的移动设备开关。
  3. 这是关于如何设置图像高度。我听说传言设置宽度(maxW)工作正常,但设置高度(maxH)在4.2以下的版本中有些错误。如果出现maxH问题,请使用替代解决方案。
相关问题