ali*_*rge 9 html5 typo3 content-management-system typoscript responsive-design
为了创建一个有Typo3和Twitter Bootstrap的响应式网站,我想删除图像的高度和宽度属性
以下是通过文本和图像和图像类型的内容元素在前端生成图像的方式
<img src="typo3temp/pics/a625b79f89.jpg" width="300" height="226" alt="blabla" />
Run Code Online (Sandbox Code Playgroud)
我想删除维度属性并得到这个:
<img src="typo3temp/pics/a625b79f89.jpg" alt="blaba" />
Run Code Online (Sandbox Code Playgroud)
谁能帮我 ?
小智 9
在document.ready函数中调用图像标记.
$('img').removeAttr('width').removeAttr('height');
Run Code Online (Sandbox Code Playgroud)
仅供参考:没有办法用typoscript删除它.在width和height属性的硬编码sysext/cms/tslib/class.tslib_content.php功能cImage.(Typo3 4.7)
无法使用打字稿删除高度或宽度图像属性。
但您可以使用 CSS 覆盖它以创建响应式网站。
img {
height:100% !important;
width:100% !important;
}
使用jQuery
为您的图像对象设置一个 id:
<img src="typo3temp/pics/a625b79f89.jpg" width="300" height="226" alt="blabla" id="myimage" />
$('#myimage').removeAttr("heigth").removeAttr("width");
Run Code Online (Sandbox Code Playgroud)
这是替代的javascript代码:
var myImage= document.getElementById("myimage");
myImage.removeAttribute("heigth");
myImage.removeAttribute("width");
Run Code Online (Sandbox Code Playgroud)