Reputation: 333
I add an image in the backend as content element. The type of this content element is "image". How can I add a css class to this img-tag?
I want something like this:
<img class="responsive" src="xyz.jpg"/>
Ho can I add a class on this image tag?
My approach:
temp.pics =CONTENT
temp.pics {
table = tt_content
select {
selectFields = image
pidInList.data = 52
andWhere = colPos=3
}
innerWrap = class="responsive" |
}
My approach isn't really ready.
Upvotes: 1
Views: 4690
Reputation: 481
If you want to apply the class to all images, you could add this line to your typoscript.
tt_content.image.20.1.params = class="class1"
If you only want the class to be added on certain images,I would recommend to use the layout field of content elements (or the alignement). You can then use the if-Statement, a condition or a CASE-object like this:
tt_content.image.20.1.params.cObject = CASE
tt_content.image.20.1.params.cObject {
key.field = layout
default = TEXT
default.value = class="class1"
1 = TEXT
1.value = class="class2"
2 = TEXT
2.value = class="class3"
}
Upvotes: 4