`;
+
// Handle image if it exists
- if (banner.Image) {
- const imageUrl = banner.Image.startsWith('http') ? banner.Image : banner.Image;
- const imageWidth = style.ImageWidth || 300;
- const imageHeight = style.ImageHeight || 200;
+ if (banner.image) {
+ const imageUrl = banner.image.startsWith('http') ? banner.image : banner.image;
+ // Use default dimensions if not specified or 0
+ const imageWidth = (style.imageWidth && style.imageWidth > 0) ? style.imageWidth : 300;
+ const imageHeight = (style.imageHeight && style.imageHeight > 0) ? style.imageHeight : 'auto';
// Create image element with styles
const imgStyle = `
max-width: 100%;
- height: auto;
+ height: ${imageHeight === 'auto' ? 'auto' : imageHeight + 'px'};
width: ${imageWidth}px;
- max-height: ${imageHeight}px;
object-fit: contain;
border-radius: ${borderRadius}px;
- ${imagePosition === 'left' ? 'float: left; margin-right: 20px;' : ''}
- ${imagePosition === 'right' ? 'float: right; margin-left: 20px;' : ''}
+ ${imagePosition === 'left' ? 'float: left; margin: 0 20px 10px 0;' : ''}
+ ${imagePosition === 'right' ? 'float: right; margin: 0 0 10px 20px;' : ''}
${imagePosition === 'center' ? 'display: block; margin: 0 auto 20px;' : ''}
+ ${imagePosition === 'top' ? 'display: block; margin: 0 auto 20px;' : ''}
+ ${imagePosition === 'bottom' ? 'display: block; margin: 20px auto 0;' : ''}
`;
// Create image container
@@ -118,15 +124,19 @@
content += imgContainer;
}
- // Add text content
+ // Add text content with proper spacing
if (banner.Text) {
+ const textStyle = `
+ margin: 0;
+ padding: 10px;
+ line-height: 1.6;
+ ${['left', 'right'].includes(imagePosition) ? 'overflow: hidden;' : 'display: block;'}
+ ${imagePosition === 'left' ? 'padding-left: 20px;' : ''}
+ ${imagePosition === 'right' ? 'padding-right: 20px;' : ''}
+ `;
+
content += `
-
+
${banner.Text.replace(/\n/g, '
')}
`;
}
@@ -135,6 +145,11 @@
if (['right', 'bottom'].includes(imagePosition)) {
content += imgContainer;
}
+
+ // Add clearfix if needed
+ if (['left', 'right'].includes(imagePosition)) {
+ content += '
';
+ }
} else {
// No image, just show text
if (banner.Text) {