FastComments.com

FastComments Image Chat enables interactive discussions on images by allowing users to click anywhere on an image to create discussion points. Users can click on specific parts of images to start conversations about those areas, creating visual markers that show where discussions are located.

This feature is perfect for design feedback, product reviews, educational materials with diagrams, photo galleries with commentary, and any scenario where you want contextual discussions anchored to specific image locations.

Responsive Design Internal Link

Percentage-Based Positioning

Image Chat uses percentage-based coordinates instead of pixel coordinates to position chat markers on images. When a user clicks on an image, the widget converts the pixel coordinates of the click into percentages of the image width and height. This approach ensures that markers remain in the correct location regardless of how the image is displayed.

For example, if a user clicks 250 pixels from the left edge of a 1000px wide image, the widget stores this as 25% from the left. When another user views the same image at 500px wide on a mobile device, the marker appears at 125 pixels from the left, which is still 25% of the width.

Benefits for Responsive Layouts

This percentage system makes Image Chat work seamlessly across all device sizes and orientations. Your images might be displayed at different sizes depending on screen width, CSS rules, or container constraints, but the markers always align correctly with the intended locations.

Users on desktop computers with large monitors see markers in the same relative positions as users on smartphones with small screens. The markers scale proportionally with the image itself.

Image Scaling and Aspect Ratio

As long as your image maintains its aspect ratio when scaling (which is the default browser behavior), the percentage-based markers will remain perfectly aligned. The widget assumes that images scale proportionally and calculates positions based on this assumption.

If you apply CSS that distorts the image aspect ratio (like using object-fit: cover with specific dimensions), the marker positions may not align correctly. For best results, allow images to scale naturally or use object-fit: contain to maintain aspect ratio.

Chat Square Sizing

The visual size of chat markers is also percentage-based. The chatSquarePercentage configuration option defaults to 5%, meaning each square is 5% of the image width. This ensures consistent visual weight across different image sizes.

On a 1000px wide image with the default 5% setting, markers are 50px square. On a 500px wide image, the same markers are 25px square. They remain proportional to the image size.

Mobile Behavior

On screens under 768px wide, Image Chat switches to a mobile-optimized layout. Chat windows open fullscreen instead of floating next to the marker. This provides better usability on small screens where floating windows would obscure too much of the image.

The markers themselves remain visible and clickable at their percentage-based positions. Users can still see where all discussions are located and tap markers to open the fullscreen chat interface.

Dynamic Image Loading

The percentage-based system works correctly even when images load asynchronously or change size after the page loads. The widget monitors the image element and recalculates marker positions whenever the image dimensions change.

If you're lazy-loading images or implementing responsive images with different sizes at different breakpoints, the markers automatically adjust when the image size changes.

Cross-Device Consistency

Because coordinates are stored as percentages in the database, a discussion created on a desktop computer appears at the exact same relative location when viewed on a tablet or phone. Users can collaborate across devices without any positioning inconsistencies.

This works bidirectionally. A discussion created by tapping a specific spot on a mobile device appears at the same relative position when viewed on a large desktop monitor.

Viewport Considerations

The widget calculates percentages relative to the image element itself, not the viewport. This means scrolling the page or changing the browser window size doesn't affect marker positions. Markers remain anchored to their locations on the image regardless of viewport changes.

Future-Proofing Content

The percentage-based approach makes your image discussions resilient to changes in layout, design, or device ecosystem. As new screen sizes and devices emerge, the existing discussions will continue to display correctly without requiring any updates or migrations.

Customization Internal Link

Dark Mode Support

Image Chat includes built-in dark mode support. When you set hasDarkBackground: true in your configuration, the chat windows and UI elements automatically adjust to work well on dark backgrounds.

FastCommentsImageChat(imageElement, {
    tenantId: 'demo',
    hasDarkBackground: true
});

The dark mode styling applies to chat windows, marker squares, and all interactive elements. If your site has a dark mode toggle, you can reinitialize the widget when the mode changes, or use the body class approach described below.

Dynamic Dark Mode

If your site's dark mode is controlled by adding a .dark class to the body element, the Image Chat UI will automatically respect this without requiring reinitialization. The widget's styles are designed to respond to the presence of this class.

/* Your dark mode CSS */
body.dark {
    background: #1a1a1a;
    color: #ffffff;
}

Custom Styling with CSS

You can customize the appearance of markers, chat windows, and other elements using CSS. The widget adds specific classes that you can target in your stylesheet.

The chat squares and windows use the FastComments comment bubble styling system, so any customizations you've applied to the standard commenting widget will also affect Image Chat.

Chat Square Sizing

The chatSquarePercentage option controls the size of the clickable markers. The default is 5% of the image width:

FastCommentsImageChat(imageElement, {
    tenantId: 'demo',
    chatSquarePercentage: 7  // Larger, more visible squares
});

Smaller values create more subtle markers that blend into the image. Larger values make markers more prominent and easier to click, especially on mobile devices or for accessibility purposes.

Mobile Behavior

On screens under 768px wide, Image Chat automatically switches to a mobile-optimized layout. Chat windows appear fullscreen instead of floating next to the markers, providing better usability on small screens.

The markers remain visible at their responsive positions on the image. Users can tap any marker to open the fullscreen chat interface. This behavior is built-in and doesn't require any configuration.

Chat Window Appearance

Chat windows are 300px wide on desktop with a 16px arrow pointing to the marker. The windows position themselves automatically based on available viewport space, using positioning classes like to-right, to-left, to-top, and to-bottom.

You can add custom CSS to adjust colors, fonts, spacing, or other visual properties of these windows. The chat windows use the same component structure as the standard FastComments widget, so they inherit any global customizations you've applied.

Lazy Initialization

Chat windows initialize on hover for desktop users or immediately when created. This reduces the initial load overhead by only rendering the chat interface when users actually interact with a marker.

The lazy initialization happens transparently. Users don't notice any delay, but the browser doesn't need to render dozens of hidden chat windows if you have many markers on an image.

Localization

Image Chat supports all the same localization options as the standard FastComments widget. Set the locale option to display UI text in different languages:

FastCommentsImageChat(imageElement, {
    tenantId: 'demo',
    locale: 'fr'  // French
});

FastComments supports dozens of languages. The locale setting affects all UI text including prompts, buttons, and placeholder text.

Inherited Customization Options

Since Image Chat extends the standard commenting widget, it inherits all customization options from the base widget. This includes custom CSS classes, custom translations, avatar customization, date formatting, and much more.

See the main FastComments customization documentation for the complete list of customization options available.

Working with Custom Fonts

If your site uses custom fonts, the Image Chat UI will inherit those fonts from your page's CSS. The chat windows render inside your page's DOM and respect your existing typography settings.

For best results, ensure your custom fonts are loaded before initializing Image Chat, or accept that there may be a brief flash of unstyled text while fonts load.

Marker Visual Design

The square markers have a subtle visual design that makes them noticeable without overwhelming the image. You can customize their appearance with CSS if you want a different visual treatment.

The markers include hover states that provide feedback when users move their mouse over them. On touch devices, the tap interaction provides immediate feedback by opening the chat window.

Live Sync Internal Link

Real-Time Updates

Image Chat uses WebSocket connections to sync all conversations in real-time across all connected users. When someone creates a new marker, adds a comment, or deletes a discussion, all other users viewing the same image see the update immediately without refreshing.

How WebSocket Sync Works

When you initialize Image Chat, the widget establishes a WebSocket connection to the FastComments servers. This connection remains open for the duration of the user's session and listens for updates related to the current image.

The WebSocket system uses three types of broadcast messages for Image Chat. The new-image-chat event fires when someone creates a new marker on the image. The image-chat-updated event fires when someone updates an existing conversation. The deleted-image-chat event fires when someone deletes a marker.

Broadcast ID System

To prevent echo effects where users see their own actions broadcast back to them, each update includes a unique broadcastId. When a user creates or updates a marker, their client generates a UUID for that operation. When the WebSocket broadcasts the update back to all clients, the originating client ignores the update because it matches its own broadcastId.

This ensures smooth interaction where users see their changes immediately in the UI without waiting for the round-trip through the server, while still ensuring all other users get the update.

Connection Resilience

If the WebSocket connection drops due to network issues or server maintenance, the widget automatically attempts to reconnect. During the reconnection period, users can still interact with existing markers, but they won't see real-time updates from other users until the connection is reestablished.

Once reconnected, the widget resynchronizes to ensure no updates were missed. This happens transparently without requiring user intervention.

Bandwidth Considerations

WebSocket messages are lightweight and contain only the essential information needed to sync state. Creating a new marker typically uses less than 1KB of bandwidth. The system also includes intelligent batching to reduce message frequency during high-activity periods.

Your usage metrics in the FastComments dashboard track pubSubMessageCount and pubSubBandwidth so you can monitor real-time sync activity across your sites.

Cross-Tab Synchronization

If a user has the same page open in multiple browser tabs, updates in one tab appear immediately in the other tabs. This works through the same WebSocket sync mechanism and doesn't require any additional configuration.

Users can have your site open on multiple devices simultaneously, and all of them will stay in sync. A marker created on a desktop computer appears instantly on the user's tablet if both devices are viewing the same image.

Security

WebSocket messages are transmitted over secure connections (WSS) and include tenant validation to ensure users only receive updates for conversations they're authorized to see. The server validates all operations before broadcasting them to prevent unauthorized access or manipulation.

Offline Behavior

When users are completely offline, they can still view existing markers but cannot create new ones or see updates from others. The widget detects the offline state and displays appropriate messaging.

If a user attempts to create a marker while offline and then comes back online, the operation will fail rather than queue, ensuring data consistency. Users should retry the operation once their connection is restored.

Performance Impact

The WebSocket connection has minimal performance impact. The connection remains idle when no updates are occurring and only processes messages when activity happens. On a typical image with moderate marker activity, the WebSocket uses less CPU than rendering the image itself.

For pages with hundreds of simultaneous users and high marker creation activity, the system scales horizontally to maintain performance without impacting individual client connections.

Collaborative Use Cases

The real-time sync makes Image Chat particularly powerful for collaborative workflows. Design teams can review mockups together with everyone seeing marker placements in real-time. Customer support teams can collaboratively annotate screenshots to identify issues. Educational groups can discuss diagrams with all participants seeing each other's markers as they're created.

The immediate feedback creates a more engaging and productive collaborative experience compared to traditional comment systems where users need to refresh to see updates.

Got Questions?

That's it for FastComments Image Chat! If you have any questions, need help with implementation, or have feature suggestions, please let us know below or reach out to our support team.

Check out the live demo on our demo page to see Image Chat in action.