12 KiB
Banner and Advertising System - Complete Documentation
Overview
The banner and advertising system provides a comprehensive solution for managing advertising spaces across the website. The system features automatic placement recommendations based on image resolution, preset dimensions for optimal display, and automatic sponsor integration.
Key Features
1. Preset-Based Banner Placements
The system includes 5 predefined banner placements with optimal dimensions:
| Placement | Dimensions | Aspect Ratio | Position | Description |
|---|---|---|---|---|
homepage_top |
1200 × 200 | 6:1 | Top | Main banner at the top of homepage, shown to all visitors |
homepage_middle |
970 × 250 | 3.88:1 | Middle | Banner in the middle of the page between content |
homepage_sidebar |
300 × 250 | 1.2:1 | Sidebar | Smaller banner in the right sidebar panel |
homepage_footer |
1200 × 200 | 6:1 | Footer | Banner at the bottom of the page before footer |
article_inline |
728 × 90 | 8.09:1 | Article | Banner displayed within article text |
2. Automatic Image Resolution Detection
When uploading a banner image:
- The system automatically detects the image resolution (width × height)
- Calculates the aspect ratio
- Provides up to 3 recommended placements based on image dimensions
- Recommends the best matching placement (highlighted as "Nejlepší")
- Displays resolution info: "Rozlišení: 1200×200 px, Poměr stran: 6.00:1"
3. Smart Placement Recommendations
The recommendation algorithm:
- Compares image aspect ratio with preset aspect ratios
- Evaluates width and height differences
- Scores each placement (lower score = better match)
- Returns top 3 recommendations ranked by quality
- Auto-selects the best match if no placement is already chosen
4. Live Preview System
- Shows banner preview in the admin modal
- Preview respects the selected placement dimensions
- Displays where the banner will appear: "Zobrazení v pozici: [Placement Label]"
- Scaled proportionally to fit admin interface (max 600px width)
5. Placement Information Display
For each placement, the system shows:
- Label: User-friendly Czech name
- Description: Detailed explanation of where and how it displays
- Dimensions: Exact pixel dimensions (read-only, automatically set)
- Aspect Ratio: Calculated ratio for reference
- Position: Logical position identifier (top, middle, sidebar, footer, article)
6. Manual Dimension Removal
- Width and height fields are removed from manual input
- Dimensions are automatically set based on selected placement preset
- This ensures consistency and prevents display issues
- Users can only select from predefined placements
7. Automatic Sponsor Integration
When a banner is created/updated:
- The banner data is stored in the
sponsorstable with placement metadata - Active banners (
is_active = true) automatically appear in:- Footer: Displayed in "Naši partneři" section with inverted logo styling
- Sponsors Page: Listed alongside regular sponsors
- Homepage Sponsors Section: Included in the sponsors grid/slider
- Provides dual functionality: advertising + partnership visibility
8. Enhanced Admin Interface
The Banners Admin Page (/admin/bannery) includes:
- Table View with columns:
- Náhled (Preview thumbnail)
- Název (Name) + URL preview
- Umístění (Placement label + position badge)
- Rozměry (Dimensions display)
- Aktivní (Active status badge)
- Akce (Edit/Delete actions)
- Modal Editor with:
- Name input
- Click-through URL (optional)
- Image upload with progress indicator
- Resolution detection alert
- Placement recommendations panel
- Placement selector with descriptions
- Dimension display (read-only)
- Live preview area
- Active toggle switch
Technical Implementation
Database Schema
Banners use the existing sponsors table with additional fields:
CREATE TABLE sponsors (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
logo_url TEXT,
website_url TEXT,
is_active BOOLEAN DEFAULT true,
tier TEXT DEFAULT 'standard',
display_order INTEGER DEFAULT 0,
placement TEXT, -- e.g., 'homepage_top'
width INTEGER, -- e.g., 1200
height INTEGER, -- e.g., 200
created_at TIMESTAMP,
updated_at TIMESTAMP
);
Frontend Components
1. BannersAdminPage.tsx
Location: frontend/src/pages/admin/BannersAdminPage.tsx
Key Functions:
getPreset(placement)- Retrieves preset configuration by placement valuerecommendPlacement(width, height)- Returns top 3 recommended placementsonUpload(file)- Handles image upload with resolution detectionopenCreate()- Opens modal with default placement presetopenEdit(sponsor)- Opens modal for editing existing banner
State Management:
editing- Current banner being editedimageResolution- Detected image dimensionsrecommendedPlacements- Array of recommended placementsuploadingImage- Upload progress indicator
2. BannerDisplay.tsx
Location: frontend/src/components/banners/BannerDisplay.tsx
Props:
interface BannerDisplayProps {
banners: Banner[];
placement: 'homepage_top' | 'homepage_middle' | 'homepage_sidebar' | 'homepage_footer' | 'article_inline';
containerStyle?: React.CSSProperties;
}
Features:
- Filters active banners for specific placement
- Applies placement-specific styling
- Handles responsive layout
- Provides hover effects
- Lazy loads images
3. Footer.tsx
Location: frontend/src/components/layout/Footer.tsx
Sponsor Display:
- Fetches sponsors from
/api/v1/public/sponsors - Filters active sponsors (
is_active !== false) - Displays in responsive grid (2-6 columns)
- Inverted logos for dark background
- Links to sponsor websites with tracking
Backend Integration
API Endpoints
GET /api/v1/public/sponsors - List all active sponsors/banners
POST /api/v1/sponsors - Create new banner (admin)
PUT /api/v1/sponsors/:id - Update banner (admin)
DELETE /api/v1/sponsors/:id - Delete banner (admin)
Sponsor Model (Go)
type Sponsor struct {
gorm.Model
Name string `gorm:"not null" json:"name"`
LogoURL string `json:"logo_url"`
WebsiteURL string `json:"website_url"`
Description string `json:"description"`
IsActive bool `gorm:"default:true" json:"is_active"`
Tier string `gorm:"default:'standard'" json:"tier"`
DisplayOrder int `gorm:"default:0" json:"display_order"`
Placement string `json:"placement"`
Width int `json:"width"`
Height int `json:"height"`
}
Display Locations
Homepage
Banners are displayed in the following locations on the homepage:
-
Top Banner (
homepage_top)- Full-width section after header
- Light gray background with borders
- Centered content
-
Middle Banner (
homepage_middle)- Between content sections
- Centered display
- Standard margin spacing
-
Sidebar Banner (
homepage_sidebar)- Right sidebar (desktop)
- Sticky positioning (top: 96px)
- Stacked on mobile
- Rounded corners with shadow
-
Footer Banner (
homepage_footer)- Above footer navigation
- Full-width with background
- Centered content
Article Pages
- Inline Banner (
article_inline)- Embedded within article content
- Standard ad format (728×90)
- Responsive on mobile
Footer
All active banners (regardless of placement) also appear as sponsors in:
- Footer "Naši partneři" section
- 6-column responsive grid
- White inverted logos on dark background
Sponsors Page
Banners are included in the sponsors page listing at /sponzori.
Usage Guide
Adding a New Banner
-
Navigate to Admin Panel
- Go to
/admin/bannery - Click "Nový banner" button
- Go to
-
Upload Image
- Click "Nahrát obrázek" button
- Select your banner image file
- System automatically detects resolution
-
Review Recommendations
- Check the detected resolution alert
- Review recommended placements (up to 3)
- Best match is highlighted in green
-
Select Placement
- Choose from dropdown or click "Použít" on recommendation
- View placement description below selector
- See dimensions display (auto-set, read-only)
-
Preview Banner
- Check live preview in modal
- Verify it matches expected dimensions
- See placement label below preview
-
Configure Details
- Enter banner name (required)
- Add website URL for click-through (optional)
- Toggle active status (default: active)
-
Save
- Click "Uložit" button
- Banner appears immediately on site
- Also added to sponsors in footer
Editing an Existing Banner
- Click edit icon (pencil) in banner table
- Modify any fields except dimensions
- Upload new image to change resolution/placement
- Save changes
Best Practices
Image Preparation
- Use correct dimensions for target placement
- High quality images (at least 2x for retina displays)
- Optimize file size (recommended: <500KB)
- Use PNG or JPG formats
- Test on mobile - ensure text is readable
Recommended Image Sizes
For best quality on retina displays:
homepage_top: 2400×400 @ 72dpihomepage_middle: 1940×500 @ 72dpihomepage_sidebar: 600×500 @ 72dpihomepage_footer: 2400×400 @ 72dpiarticle_inline: 1456×180 @ 72dpi
Naming Convention
Use descriptive names:
- ❌ Bad: "Banner 1", "IMG_1234"
- ✅ Good: "Hlavní partner 2025", "Turnaj léto 2025"
URL Configuration
- Always use
https://protocol - Test link before saving
- Use tracking parameters if needed:
?utm_source=banner&utm_medium=homepage
Active Status
- Set to active only when campaign is live
- Deactivate expired campaigns instead of deleting
- Keeps historical data and analytics
Troubleshooting
Issue: Banner not displaying
Solutions:
- Check
is_activestatus istrue - Verify placement matches homepage style
- Clear browser cache
- Check image URL is accessible
Issue: Wrong placement recommendations
Cause: Image aspect ratio doesn't match any preset closely
Solutions:
- Resize image to match recommended dimensions
- Choose closest preset manually
- Accept that banner may not perfectly fit
Issue: Image resolution not detected
Cause: Browser security/CORS issues
Solutions:
- Upload image again
- Try different image format
- Check image file integrity
- Use supported format (JPG/PNG/WebP)
Issue: Banner overlaps content
Cause: Custom styling conflicts
Solutions:
- Use preset placements only
- Don't modify width/height manually
- Check responsive behavior on mobile
Issue: Sponsor not showing in footer
Cause: Banner not marked as active or API error
Solutions:
- Verify
is_active = true - Check API endpoint
/api/v1/public/sponsors - Refresh page to reload sponsors
- Check browser console for errors
Future Enhancements
Potential improvements:
- A/B testing for banner effectiveness
- Click-through tracking and analytics
- Impression counting
- Scheduled banner campaigns (start/end dates)
- Banner rotation for same placement
- Custom placement creation
- Banner templates library
- Bulk upload functionality
- Performance metrics dashboard
Technical Notes
Performance Considerations
- Images use
loading="lazy"for off-screen banners - Responsive images with
object-fit: contain - Minimal re-renders with React state management
- Cached sponsor data in footer
Accessibility
- All banners have descriptive
alttext - Clickable areas use semantic
<a>tags - Keyboard navigation support
- ARIA labels where appropriate
Security
- Image uploads validate file types
- URLs sanitized before storage
- External links use
rel="noopener noreferrer" - XSS protection on user inputs
Support
For issues or questions about the banner system:
- Check this documentation first
- Review browser console for errors
- Test with different image formats
- Contact system administrator
Last Updated: 2025-01-12 Version: 1.0 Maintained by: MyClub Development Team