Featured Images Component
Learn how to use and customize featured images in Arsxy Theme
Featured images enhance the visual appeal of your content and provide a preview of your posts. Arsxy Theme includes robust support for featured images across various layouts.
Adding Featured Images to Posts
To add a featured image to a post, include the image
front matter variable:
---
layout: post
title: "My Blog Post"
description: "A description of my blog post"
image: /assets/images/posts/featured-image.jpg
---
Image Display Locations
Featured images appear in several locations throughout the theme:
- Post Headers: At the top of individual posts
- Post Lists: As thumbnails in post listing pages
- Related Posts: As thumbnails in the related posts section
- Social Sharing Cards: Used when your content is shared on social media
Automatic Featured Images
If you don’t specify a featured image, Arsxy Theme can generate one automatically based on the post title. To enable this feature, add the following to your _config.yml
:
featured_images:
auto_generate: true
text_color: "#ffffff"
background_color: "#1a1a1a"
font: "Roboto"
Image Size Recommendations
For optimal display across all devices, use the following image dimensions:
- Recommended size: 1200×630 pixels
- Minimum size: 600×315 pixels
- Aspect ratio: 1.91:1
Image Optimization
To improve page load times, Arsxy Theme automatically applies responsive image techniques:
- Responsive srcset: Multiple image sizes for different devices
- Lazy loading: Images load only when scrolled into view
Example of the HTML generated:
<img src="/assets/images/posts/featured-image.jpg"
srcset="/assets/images/posts/featured-image-small.jpg 400w,
/assets/images/posts/featured-image-medium.jpg 800w,
/assets/images/posts/featured-image.jpg 1200w"
sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, 1200px"
alt="Post title"
loading="lazy">
Customizing Featured Image Display
Overlay Options
You can add text overlays on featured images by setting options in the front matter:
---
image: /assets/images/posts/featured-image.jpg
image_overlay:
title: true # Show post title on the image
text_color: "#ffffff"
gradient: "linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.7))"
---
Cropping Behavior
Control how featured images are cropped and displayed:
---
image: /assets/images/posts/featured-image.jpg
image_options:
position: "center" # Options: top, center, bottom
crop: "fill" # Options: fill, fit, none
---
Alternatively, set global defaults in your _config.yml
:
featured_images:
position: "center"
crop: "fill"
Styling Featured Images
You can customize the appearance of featured images by modifying the CSS in _sass/components/_image.scss
:
.featured-image {
border-radius: 8px;
margin-bottom: 1.5rem;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
// Caption styles
figcaption {
font-size: 0.9rem;
color: var(--text-secondary);
text-align: center;
padding-top: 0.5rem;
}
}
Image Captions
Add captions to your featured images with the image_caption
front matter variable:
---
image: /assets/images/posts/featured-image.jpg
image_caption: "Photo by Jane Doe on Unsplash"
---
Full-width Images
For extra impact, make featured images span the full width of the page:
---
image: /assets/images/posts/featured-image.jpg
image_fullwidth: true
---
Accessibility Considerations
For better accessibility:
- Always include descriptive alt text for your images
- Ensure sufficient contrast between any text overlay and the image
- Don’t rely solely on images to convey important information
---
image: /assets/images/posts/featured-image.jpg
image_alt: "Detailed description of the image content" # Will fallback to post title if not specified
---