Skip to content

secondsky/claude-skills / plugins/cloudflare-images/skills/cloudflare-images

cloudflare-images

Unverified

This skill should be used when the user asks to "upload images to Cloudflare", "implement direct creator upload", "configure image transformations", "optimize WebP/AVIF", "create image variants", "generate signed URLs", "add image watermarks", "integrate with Next.js/Remix", "configure webhooks", "debug CORS errors", "troubleshoot error 5408/9401-9413", or "build responsive images with Cloudflare Images API".

FileKindSize
SKILL.mdskill md13.9 KB
assets/diagrams/direct-upload-workflow.mdmarkdown5.0 KB
assets/diagrams/transformation-pipeline.mdmarkdown8.2 KB
assets/diagrams/variants-structure.mdmarkdown10.6 KB
examples/basic-upload/.env.exampleother474 B
examples/basic-upload/README.mdmarkdown6.5 KB
examples/basic-upload/package.jsonmanifest542 B
examples/basic-upload/public/index.htmlother12.7 KB
examples/basic-upload/src/index.tsscript2.7 KB
examples/basic-upload/wrangler.jsoncother378 B
examples/private-images/.env.exampleother631 B
examples/private-images/README.mdmarkdown12.5 KB
examples/private-images/package.jsonmanifest741 B
examples/private-images/public/index.htmlother18.0 KB
examples/private-images/src/index.tsscript5.2 KB
examples/private-images/wrangler.jsoncother427 B
examples/responsive-gallery/README.mdmarkdown4.3 KB
references/api-reference.mdmarkdown8.1 KB
references/content-credentials.mdmarkdown11.6 KB
references/custom-domains.mdmarkdown10.5 KB
references/direct-upload-complete-workflow.mdmarkdown11.2 KB
references/format-optimization.mdmarkdown7.2 KB
references/framework-integration.mdmarkdown15.4 KB
references/overlays-watermarks.mdmarkdown11.1 KB
references/polish-compression.mdmarkdown10.4 KB
references/responsive-images-patterns.mdmarkdown6.1 KB
references/setup-guide.mdmarkdown3.8 KB
references/signed-urls-guide.mdmarkdown7.5 KB
references/sourcing-kit.mdmarkdown15.0 KB
references/top-errors.mdmarkdown11.7 KB
references/transformation-options.mdmarkdown6.4 KB
references/variants-guide.mdmarkdown6.7 KB
references/webhooks-guide.mdmarkdown11.8 KB
scripts/analyze-usage.shexecutablescript6.6 KB
scripts/check-versions.shexecutablescript3.3 KB
scripts/generate-signed-url.shexecutablescript4.4 KB
scripts/test-upload.shexecutablescript4.4 KB
scripts/validate-variants.shexecutablescript5.2 KB
templates/batch-upload.tsscript7.8 KB
templates/direct-creator-upload-backend.tsscript5.4 KB
templates/direct-creator-upload-frontend.htmlother8.4 KB
templates/nextjs-integration.tsxother11.4 KB
templates/overlay-watermark.tsscript13.7 KB
templates/package.jsonmanifest387 B
templates/remix-integration.tsxother15.0 KB
templates/responsive-images-srcset.htmlother8.0 KB
templates/signed-urls-generation.tsscript6.6 KB
templates/transform-via-url.tsscript6.5 KB
templates/transform-via-workers.tsscript8.7 KB
templates/upload-api-basic.tsscript3.8 KB
templates/upload-via-url.tsscript4.9 KB
templates/variants-management.tsscript7.0 KB
templates/webhook-handler.tsscript8.8 KB
templates/wrangler-images-binding.jsoncother1.2 KB

examples/basic-upload/public/index.html

View on GitHub
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Cloudflare Images - Basic Upload Example</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .container {
            background: white;
            border-radius: 16px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.3);
            padding: 40px;
            max-width: 600px;
            width: 100%;
        }

        h1 {
            color: #333;
            margin-bottom: 10px;
            font-size: 28px;
        }

        .subtitle {
            color: #666;
            margin-bottom: 30px;
            font-size: 14px;
        }

        .upload-form {
            margin-bottom: 30px;
        }

        .file-input-wrapper {
            position: relative;
            margin-bottom: 20px;
        }

        input[type="file"] {
            width: 100%;
            padding: 15px;
            border: 2px dashed #ddd;
            border-radius: 8px;
            cursor: pointer;
            font-size: 14px;
            transition: border-color 0.3s;
        }

        input[type="file"]:hover {
            border-color: #667eea;
        }

        .upload-button {
            width: 100%;
            padding: 15px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.2s, opacity 0.3s;
        }

        .upload-button:hover:not(:disabled) {
            transform: translateY(-2px);
        }

        .upload-button:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        .progress-container {
            display: none;
            margin-bottom: 20px;
        }

        .progress-bar {
            width: 100%;
            height: 8px;
            background: #f0f0f0;
            border-radius: 4px;
            overflow: hidden;
        }

        .progress-fill {
            height: 100%;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            width: 0%;
            transition: width 0.3s;
        }

        .progress-text {
            margin-top: 8px;
            color: #666;
            font-size: 14px;
            text-align: center;
        }

        .error {
            background: #fee;
            color: #c33;
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
            border-left: 4px solid #c33;
            display: none;
        }

        .success {
            background: #efe;
            color: #3c3;
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
            border-left: 4px solid #3c3;
            display: none;
        }

        .uploaded-image-container {
            display: none;
            text-align: center;
        }

        .uploaded-image-container h2 {
            color: #333;
            margin-bottom: 15px;
            font-size: 20px;
        }

        .uploaded-image {
            max-width: 100%;
            border-radius: 8px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        }

        .image-details {
            margin-top: 15px;
            padding: 15px;
            background: #f8f8f8;
            border-radius: 8px;
            text-align: left;
            font-size: 13px;
            color: #666;
        }

        .image-details div {
            margin: 5px 0;
        }

        .image-details strong {
            color: #333;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🖼️ Cloudflare Images Upload</h1>
        <p class="subtitle">Basic Upload Example - Direct Creator Upload Pattern</p>

        <div class="error" id="error"></div>
        <div class="success" id="success"></div>

        <form class="upload-form" id="upload-form">
            <div class="file-input-wrapper">
                <input
                    type="file"
                    id="file-input"
                    accept="image/jpeg,image/png,image/webp,image/gif"
                    required
                />
            </div>

            <div class="progress-container" id="progress-container">
                <div class="progress-bar">
                    <div class="progress-fill" id="progress-fill"></div>
                </div>
                <div class="progress-text" id="progress-text">Uploading... 0%</div>
            </div>

            <button type="submit" class="upload-button" id="upload-button">
                Upload Image
            </button>
        </form>

        <div class="uploaded-image-container" id="uploaded-image-container">
            <h2>✅ Upload Successful!</h2>
            <img class="uploaded-image" id="uploaded-image" alt="Uploaded image">
            <div class="image-details" id="image-details"></div>
        </div>
    </div>

    <script>
        // Configuration
        const API_URL = 'http://localhost:8787'; // Change to your Worker URL in production
        const ACCOUNT_HASH = 'your_account_hash_here'; // Replace with your actual account hash

        // DOM elements
        const form = document.getElementById('upload-form');
        const fileInput = document.getElementById('file-input');
        const uploadButton = document.getElementById('upload-button');
        const progressContainer = document.getElementById('progress-container');
        const progressFill = document.getElementById('progress-fill');
        const progressText = document.getElementById('progress-text');
        const errorDiv = document.getElementById('error');
        const successDiv = document.getElementById('success');
        const uploadedImageContainer = document.getElementById('uploaded-image-container');
        const uploadedImage = document.getElementById('uploaded-image');
        const imageDetails = document.getElementById('image-details');

        // Form submit handler
        form.addEventListener('submit', async (e) => {
            e.preventDefault();
            await uploadImage();
        });

        async function uploadImage() {
            // Get selected file
            const file = fileInput.files[0];
            if (!file) {
                showError('Please select a file');
                return;
            }

            // Validate file size (max 10MB)
            const maxSize = 10 * 1024 * 1024;
            if (file.size > maxSize) {
                showError(`File too large (${(file.size / 1024 / 1024).toFixed(1)}MB). Maximum size is 10MB.`);
                return;
            }

            // Validate file type
            const allowedTypes = ['image/jpeg', 'image/png', 'image/webp', 'image/gif'];
            if (!allowedTypes.includes(file.type)) {
                showError('Invalid file type. Please upload JPEG, PNG, WebP, or GIF.');
                return;
            }

            try {
                // Reset UI
                hideError();
                hideSuccess();
                uploadedImageContainer.style.display = 'none';

                // Disable form
                uploadButton.disabled = true;
                fileInput.disabled = true;

                // Show progress
                showProgress(10);

                // Step 1: Get one-time upload URL from our Worker
                console.log('Requesting upload URL from Worker...');
                const urlResponse = await fetch(`${API_URL}/api/upload-url`, {
                    method: 'POST'
                });

                if (!urlResponse.ok) {
                    throw new Error(`Failed to get upload URL: ${urlResponse.statusText}`);
                }

                const { uploadURL, imageId } = await urlResponse.json();
                console.log('Got upload URL. Image ID:', imageId);

                showProgress(30);

                // Step 2: Upload file directly to Cloudflare Images
                console.log('Uploading file to Cloudflare...');
                const uploadFormData = new FormData();
                uploadFormData.append('file', file);

                const xhr = new XMLHttpRequest();

                // Track upload progress
                xhr.upload.addEventListener('progress', (e) => {
                    if (e.lengthComputable) {
                        const percentComplete = 30 + Math.round((e.loaded / e.total) * 60);
                        showProgress(percentComplete);
                    }
                });

                // Handle upload completion
                const uploadPromise = new Promise((resolve, reject) => {
                    xhr.addEventListener('load', () => {
                        if (xhr.status === 200) {
                            resolve();
                        } else {
                            reject(new Error(`Upload failed: ${xhr.statusText}`));
                        }
                    });

                    xhr.addEventListener('error', () => {
                        reject(new Error('Network error during upload'));
                    });
                });

                xhr.open('POST', uploadURL);
                xhr.send(uploadFormData);

                await uploadPromise;
                showProgress(100);

                console.log('Upload successful!');

                // Step 3: Display uploaded image
                const imageUrl = `https://imagedelivery.net/${ACCOUNT_HASH}/${imageId}/public`;
                uploadedImage.src = imageUrl;

                // Build details with the DOM API rather than innerHTML: file.name
                // is user-controlled, so interpolating it into innerHTML would be
                // DOM XSS. textContent never parses as HTML, so it is safe here.
                imageDetails.replaceChildren();
                const detailRows = [
                    ['Image ID', imageId],
                    ['Filename', file.name],
                    ['Size', `${(file.size / 1024).toFixed(1)} KB`],
                    ['Type', file.type],
                ];
                for (const [label, value] of detailRows) {
                    const row = document.createElement('div');
                    const strong = document.createElement('strong');
                    strong.textContent = `${label}:`;
                    row.append(strong, ' ', value);
                    imageDetails.append(row);
                }
                const urlRow = document.createElement('div');
                const urlLabel = document.createElement('strong');
                urlLabel.textContent = 'URL:';
                const urlLink = document.createElement('a');
                urlLink.href = imageUrl;
                urlLink.target = '_blank';
                urlLink.textContent = imageUrl;
                urlRow.append(urlLabel, ' ', urlLink);
                imageDetails.append(urlRow);

                uploadedImageContainer.style.display = 'block';
                showSuccess('Image uploaded successfully!');

                // Reset form
                form.reset();

            } catch (error) {
                console.error('Upload error:', error);
                showError(error.message);
            } finally {
                // Re-enable form
                uploadButton.disabled = false;
                fileInput.disabled = false;
                hideProgress();
            }
        }

        // UI helper functions
        function showProgress(percent) {
            progressContainer.style.display = 'block';
            progressFill.style.width = `${percent}%`;
            progressText.textContent = `Uploading... ${percent}%`;
        }

        function hideProgress() {
            setTimeout(() => {
                progressContainer.style.display = 'none';
                progressFill.style.width = '0%';
            }, 500);
        }

        function showError(message) {
            errorDiv.textContent = message;
            errorDiv.style.display = 'block';
        }

        function hideError() {
            errorDiv.style.display = 'none';
        }

        function showSuccess(message) {
            successDiv.textContent = message;
            successDiv.style.display = 'block';
        }

        function hideSuccess() {
            successDiv.style.display = 'none';
        }
    </script>
</body>
</html>
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall