Hello,
i try to make the following possible in my theme:
Images should be alway in a grid of 2 rows. Except for the case that Full with is chosen. Like here:
The left Image has margin on the right and the right image has margin left.
I managed to so with changing automad/blocks/image with the following code:
if (!empty($data->stretched)) {
$figureAttr = 'class="am-stretched" style="width: 100; padding: 1% 0;"';
}else{
$figureAttr = 'class="twoByTwo" ';
}
And i added a Javascript to add the margin:
async function twoByTwoFunction() {
let twoByTwo1 = document.getElementsByClassName('twoByTwo').length;
for (let i = 0; i < document.getElementsByClassName('twoByTwo').length; i++) {
if (i % 2 == 0) {
document.getElementsByClassName('twoByTwo')[i].style.marginRight = '1%';
} else {
document.getElementsByClassName('twoByTwo')[i].style.marginLeft = '1%';
var mybr = document.createElement('br');
mybr.appendAfter(document.getElementsByClassName('twoByTwo')[i]);
}
}
}
That way it works for me. But the changes in automad/blocks/image will be lost after the next update.
Is there an easier way to archive what i want, without touching automad/blocks/image?
Cheers,
Dennis