name: cloudinary-media description: Enforces project Cloudinary media conventions when working with image uploads, URL generation, transformations, social sharing images, and photo management components. This skill covers the complete media workflow including CloudinaryService operations, URL utilities, CldImage/CldUploadWidget components, path organization, type definitions, and Sentry integration.
Cloudinary Media Skill
Purpose
This skill enforces the project Cloudinary media conventions automatically during media-related development. It ensures consistent patterns for image uploads, URL transformations, social sharing images, photo management, error handling with Sentry, and proper type usage across the application.
Activation
This skill activates when:
- Working with image uploads using
CldUploadWidgetorCloudinaryService - Using
CldImagecomponent fromnext-cloudinaryfor image display - Generating optimized URLs with
cloudinary.utilsfunctions - Creating social sharing images (OG, Twitter) for SEO metadata
- Extracting publicIds or formats from Cloudinary URLs
- Implementing photo galleries, avatars, or image displays
- Working with
CloudinaryPhototype or related interfaces - Using
CloudinaryPathBuilderorCLOUDINARY_PATHSconstants - Implementing photo upload components with progress tracking
- Working with files in
src/lib/utils/cloudinary.utils.ts - Working with files in
src/lib/services/cloudinary.service.ts - Working with files in
src/lib/constants/cloudinary-paths.ts - Working with files in
src/types/cloudinary.types.ts - Working with files in
src/components/ui/cloudinary-*.tsx
Workflow
- Detect Cloudinary work (file path contains
cloudinary, imports fromnext-cloudinary, or uses cloudinary utilities) - Load
references/Cloudinary-Media-Conventions.md - Generate/modify code following all conventions
- Scan for violations of media patterns
- Auto-fix all violations (no permission needed)
- Report fixes applied
Key Patterns
Image Display
- Use
CldImagefromnext-cloudinaryfor all Cloudinary images - Pass
publicIdtosrcprop (not full URL) - Always include
alt,crop,gravity,quality={'auto'}props - Use
sizesprop for responsive images withfill - Extract publicId using
extractPublicIdFromCloudinaryUrl()when needed
URL Generation
- Use
generateOpenGraphImageUrl()for OG images (1200x630) - Use
generateTwitterCardImageUrl()for Twitter cards (800x418) - Use
generateSocialImageUrl()for platform-specific dimensions - Use
extractFormatFromCloudinaryUrl()to get file extensions - All utilities include Sentry error logging with fallbacks
Upload Service
- Use
CloudinaryServicestatic methods for server-side operations - Use
deletePhotosByUrls()for batch deletion with URL context - Use
movePhotosToPermFolder()to move temp uploads to permanent locations - Use
getOptimizedUrl()for programmatic URL generation - All service methods use circuit breakers and retry logic
Path Organization
- Use
CLOUDINARY_PATHS.FOLDERSfor base folder names - Use
CloudinaryPathBuilderfunctions for dynamic paths:bobbleheadPath(userId, collectionId, bobbleheadId)collectionCoverPath(userId, collectionId)profilePath(userId)tempPath(userId)
- Never hardcode folder paths directly
Type Definitions
- Use
CloudinaryPhotointerface for photo data - Use
transformCloudinaryResult()to convert upload results - Use
PhotoUploadStatefor tracking upload progress - Use
FileUploadProgressfor individual file tracking - Use type guards
isPersistedPhoto()andisTempPhoto()
Upload Components
- Use
CloudinaryPhotoUploadcomponent for photo management - Configure
CldUploadWidgetwith proper options and signature endpoint - Implement optimistic updates with blob URLs during upload
- Handle upload errors with retry capability
- Support bulk selection and deletion
Error Handling
- All utilities log errors to Sentry with operation context
- Return sensible fallbacks on error (default image, original URL)
- Use
createServiceErrorfor service-level errors - Track upload failures with
uploadErrorproperty
References
references/Cloudinary-Media-Conventions.md- Complete Cloudinary media conventions