Skip to content

Commit c191d8b

Browse files
Stack testimonial generator sections vertically (#93)
- ensured avatar preview requests use anonymous CORS with no referrer to avoid cross-origin 403 errors when loading external photos. - added shared fetch options (CORS mode, no-referrer policy, image-friendly Accept headers) so html-to-image fetches avatars successfully during export. - set avatar preview to request images anonymously without referrers to avoid cross-origin 403s - provide html-to-image with fetch options and image-friendly Accept headers for rendering - arrange the testimonial form above the preview so inputs appear first and the image card sits below ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_69452e5bb00c832580cef83c63564991)
1 parent 16223f3 commit c191d8b

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

testimonial-card-generator.html

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,10 @@
1919
}
2020

2121
.layout {
22-
display: grid;
23-
grid-template-columns: 1fr;
22+
display: flex;
23+
flex-direction: column;
2424
gap: clamp(1rem, 3vw, 1.5rem);
25-
align-items: start;
26-
}
27-
28-
@media (min-width: 1100px) {
29-
.layout {
30-
grid-template-columns: minmax(320px, 1fr) auto;
31-
}
25+
align-items: stretch;
3226
}
3327

3428
.field {
@@ -236,7 +230,7 @@ <h1>Testimonial Card Image Generator</h1>
236230
<div class="card" id="card">
237231
<blockquote id="quote">Add your testimonial to see a preview.</blockquote>
238232
<div class="person">
239-
<img class="avatar" id="avatar" src="" alt="Avatar preview">
233+
<img class="avatar" id="avatar" src="" alt="Avatar preview" crossorigin="anonymous" referrerpolicy="no-referrer">
240234
<div>
241235
<div class="name" id="previewName">Name</div>
242236
<div class="affiliation" id="previewAffiliation">Affiliation</div>
@@ -353,13 +347,22 @@ <h1>Testimonial Card Image Generator</h1>
353347
.replace(/(^-|-$)/g, '') || 'person-name';
354348
}
355349

350+
const fetchOptions = {
351+
mode: 'cors',
352+
referrerPolicy: 'no-referrer',
353+
headers: {
354+
Accept: 'image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8',
355+
},
356+
};
357+
356358
async function downloadImage() {
357359
status.textContent = 'Rendering image...';
358360
downloadButton.disabled = true;
359361
try {
360362
const dataUrl = await htmlToImage.toPng(renderSurface, {
361363
pixelRatio: 2,
362364
backgroundColor: 'rgba(0,0,0,0)',
365+
fetchRequestInit: fetchOptions,
363366
});
364367

365368
const link = document.createElement('a');

0 commit comments

Comments
 (0)