Skip to content

feat: implement responsive images (#255)#344

Merged
RUKAYAT-CODER merged 1 commit intorinafcode:mainfrom
omonxooo-commits:fix/255-responsive-images
Apr 28, 2026
Merged

feat: implement responsive images (#255)#344
RUKAYAT-CODER merged 1 commit intorinafcode:mainfrom
omonxooo-commits:fix/255-responsive-images

Conversation

@omonxooo-commits
Copy link
Copy Markdown
Contributor

Summary

Closes #255

Implements responsive image support to fix oversized images being served to mobile users.

Changes

src/lib/image-optimizer/index.ts

  • getOptimizedUrl() — builds CDN-transformed URLs for Cloudinary and Imgix; falls back to original src for Next.js native optimization
  • buildSrcSet() — generates a srcset string for a given set of widths
  • SIZES — predefined responsive sizes attribute values (full, half, third, avatar)

src/components/ResponsiveImage.tsx

  • Wraps next/image (which handles WebP/AVIF automatically via next.config.ts)
  • Native lazy loading (loading="lazy") by default; disabled when priority is set
  • Optional Cloudinary / Imgix CDN URL building via provider prop
  • Graceful fallbackSrc on image load error
  • Accessible: enforces alt prop

How to use

// Basic (Next.js native optimization)
<ResponsiveImage src="/hero.jpg" alt="Hero" width={1200} height={600} />

// With predefined sizes
<ResponsiveImage src="/card.jpg" alt="Card" width={400} height={300} responsiveSizes="half" />

// With Cloudinary CDN
<ResponsiveImage
  src="https://example.com/photo.jpg"
  alt="Photo"
  width={800}
  height={600}
  provider="cloudinary"
  optimizerOptions={{ quality: 80 }}
/>

Acceptance Criteria

  • Images serve appropriate size for device (via srcset + sizes)
  • Lazy loading enabled by default
  • WebP/AVIF format support (Next.js image.formats already configured)
  • CDN integration (Cloudinary, Imgix)
  • No console errors — graceful fallback on broken images

- Add src/lib/image-optimizer/index.ts with CDN URL builders
  (Next.js native, Cloudinary, Imgix) and srcset/sizes helpers
- Add src/components/ResponsiveImage.tsx wrapping next/image with
  lazy loading, WebP/AVIF support, CDN integration, and error fallback

Closes rinafcode#255
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 28, 2026

@omonxooo-commits Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER RUKAYAT-CODER merged commit bd04868 into rinafcode:main Apr 28, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Responsive Images

2 participants