Webflow sync, pageviews & more.
NEW

Can I insert custom code in Webflow to load images that are not loading with the default embed code?

TL;DR
  • Use the Embed element with a valid <img> tag and ensure the image URL is publicly accessible without CORS issues.
  • Add custom code in Page Settings if loading images dynamically, and publish the site to test changes live.

Yes, you can use custom code in Webflow to load images that aren't working with default embed methods, especially when using external URLs or dynamic contexts.

1. Use Embed Element for Custom Code

  • Use the Embed element (from the Add panel under Components) to manually add custom image HTML if the standard Image element isn't working.
  • Insert an HTML <img> tag with the image URL:
    <img src="https://example.com/image.jpg" alt="Descriptive text" loading="lazy">
  • Make sure the URL is valid and accessible (not blocked by CORS or requiring authentication).

2. Check Image Permissions and CDN Settings

  • Ensure the image URL is publicly accessible and doesn't require a login.
  • Images hosted on third-party services (like Dropbox or Google Drive) may not load due to cross-origin restrictions or improper content headers. Use an image from a proper CDN or image hosting provider.

3. Use Custom Scripts (if required)

  • If you're loading images dynamically (e.g., from an API), place the code in the Page Settings > Custom Code > Before section.
  • You may use JavaScript to create and append image elements to the DOM.
  • Make sure the image insertion script runs after Webflow loads (e.g., wrap it in a DOMContentLoaded listener).

4. Verify with Publish

  • Custom code only appears on the published site, not inside the Webflow Designer.
  • Always click Publish to selected domains and test the image load on the live URL.

Summary

To fix images not loading with Webflow's embed, use the Embed element with a standard <img> tag, ensure the image source is accessible, avoid services with CORS restrictions, and add custom code in Page Settings if scripting is required. Always publish to test changes.

Rate this answer

Other Webflow Questions