Fix: Google Drive Images Not Showing In Experience Cloud
Hey everyone! Today, we're diving deep into a frustrating issue many of you might have encountered: Google Drive image links failing to display correctly in Salesforce Experience Cloud. If you've been struggling to get your Google Drive images to show up in your Experience Cloud site, you're in the right place. Let's break down the problem, explore the attempted solutions, and nail down a fix that actually works. This article will guide you through each step, ensuring your images display perfectly. So, let's jump right in!
The Problem: Google Drive URLs as Direct Image Sources
So, here's the deal. When you try to use a standard Google Drive file URL as a direct image source in Experience Cloud, it just doesn't work. You might think, "Hey, I've got this image in Google Drive, it's shared publicly, so I can just grab the link and pop it into my <img> tag." But, nope, Experience Cloud throws a fit.
You see, Experience Cloud needs a direct link to the actual image data, not just a link to a Google Drive page. The main issue is that Google Drive URLs, by default, point to a webpage that displays the image rather than the raw image file itself. This is a common head-scratcher, and it's crucial to understand why those seemingly straightforward URLs don't cut it. We’ll get this fixed, no sweat! We've tried a bunch of different URL formats, and none of them seemed to do the trick. Let's walk through what we've tried so far:
Attempts to Solve the Issue
Attempt 1: Standard File URL
The first thing we tried was the standard Google Drive file URL. You know, the one you get when you click "Share" and copy the link. It looks something like this:
https://drive.google.com/file/d/YOUR_FILE_ID/view?usp=sharing
Result: This gives you a link to the Google Drive page where the image is displayed, not the image itself. So, Experience Cloud just sees a webpage and says, "Nope, not a direct image source!" The URL directs to a Google Drive page link rather than the image data, leading to display failure within Experience Cloud.
Attempt 2: Google Drive Preview URL
Next up, we tried the Google Drive Preview URL. This one seems like it should work, right? It looks a bit more like a direct link:
https://lh3.googleusercontent.com/d/YOUR_FILE_ID
Result: Unfortunately, this returns an HTML page wrapper instead of the raw image. Bummer! The console throws an error saying it's "not a direct link to image content." While it appears closer to a direct image link, it still provides an HTML page wrapper, not the raw image data required by Experience Cloud. This method, despite seeming promising, ultimately fails.
Attempt 3: Export View Format
Okay, let's try exporting the image. Google Drive has this handy export=view parameter, so we thought we were onto something:
https://drive.google.com/uc?export=view&id=YOUR_FILE_ID
Result: Nope, still returns an HTML page. We got the same console error – not direct image content. The export=view parameter was designed to directly serve the image content, but it also falls short, as it still serves an HTML page rather than the raw image data.
Attempt 4: iFrame Embed (Testing)
Alright, this one's a bit different. We thought, "What if we embed the image using an <iframe> tag?" This might bypass the direct image URL requirement:
<iframe src="https://drive.google.com/file/d/YOUR_FILE_ID/preview"
width="400-512" height="400-512" frameborder="0" allow="autoplay">
</iframe>
Status: This is currently being tested! We need to manually publish the site to see if it works. The big question is whether Experience Cloud will sanitize or allow <iframe> tags. This method explores embedding the image to circumvent direct URL requirements. The success hinges on Experience Cloud’s handling of <iframe> tags.
Impact of the Issue
This issue is a major blocker. We can't migrate our Asset Files to Google Drive, which means we're stuck with Salesforce's limited file storage (20MB in Developer Edition). This is causing contact record creation to fail due to storage limitations, and it's putting our Google Drive integration strategy at risk. It’s vital we find a workaround to keep our project on track.
Steps to Reproduce the Issue
Want to see this in action yourself? Here’s how to reproduce the issue:
- Create a Google Drive file with public sharing enabled ("Anyone with the link").
- Grab the File ID.
- Try to use the Google Drive URL in an
<img>tag within Experience Cloud rich text. - Publish the site and test it out.
- Check your browser console for the error: "not a direct link to image content."
Code Snippets That Don't Work
Here's the code we've been using that doesn't work. This should give you a clearer picture of what we've tried:
Attempt with <img> tag:
"richTextValue" : "<img class='sfdcCbImage' alt='CVMA Lucky 7 Logo' src='https://drive.google.com/uc?export=view&id=YOUR_FILE_ID'>"
Testing with <iframe> tag:
"richTextValue" : "<iframe src='https://drive.google.com/file/d/YOUR_FILE_ID/preview' width='512' height='512' frameborder='0' allow='autoplay'></iframe>"
Expected vs. Actual Behavior
Expected: Google Drive images should display directly in Experience Cloud when:
- The file is shared publicly.
- A direct image URL is used in the
<img>tag'ssrcattribute. - Experience Cloud allows external image URLs.
Actual:
- All tested Google Drive URLs return HTML pages instead of raw image data.
- The browser console shows the error: "That's still a Google Drive file page link, not a direct link to the image content itself."
- Images fail to render on Experience Cloud pages.
Possible Solutions: Let's Crack This!
Okay, so we've hit a snag. But don't worry, we've got some potential solutions lined up. Let's explore them:
Option 1: iFrame Embed (User Suggested - Testing)
As mentioned earlier, we’re testing the <iframe> approach. If it works, it could be a simple way to bypass the direct image URL requirement. However, we need to ensure Experience Cloud doesn't sanitize <iframe> tags for security reasons. If successful, this is a straightforward workaround.
Option 2: Static Resources (Fallback - Guaranteed to Work)
The reliable fallback is to upload the image to Salesforce Static Resources. This guarantees compatibility with Experience Cloud. Plus, it uses code storage (5MB limit) rather than file storage (20MB limit), which is a big win. However, it does use up some code storage, and updating the image requires a deployment. This is the reliable fallback, ensuring compatibility but requiring deployments for updates.
Option 3: External CDN (Alternative)
We could also use an external Content Delivery Network (CDN) like Cloudinary, Imgur, or ImgBB. These services provide direct image URLs and often have free tiers available. The downside is the external dependency and potential costs for commercial use. CDNs offer direct image URLs and free tiers but introduce external dependencies and potential costs.
Option 4: ContentDocument Hybrid (Research Needed)
This option involves creating ContentDocument records with external URL references. It might provide better integration with Experience Cloud, but we need to investigate further to see if it's supported. Further investigation is needed to determine the viability of this approach.
Investigation: Time to Put on Our Detective Hats!
We need to investigate a few key areas to solve this puzzle:
- [ ] Finish testing the
<iframe>embed after manual publish. - [ ] Research Experience Cloud CSP (Content Security Policy) for external images.
- [ ] Check if the Google Drive API provides direct image URLs.
- [ ] Evaluate the trade-offs between Static Resources and Google Drive for our strategy.
- [ ] Document the working solution in a migration guide.
Related Files: Where We're Working
Here are some of the files we're working with. This helps to show you where the issue is popping up in our project:
src/experiences/Combat_Veterams_Motorcycle_Association1/views/login.jsonsrc/experiences/Combat_Veterams_Motorcycle_Association1/views/register.jsonsrc/experiences/Combat_Veterams_Motorcycle_Association1/views/checkPassword.jsonsrc/experiences/Combat_Veterams_Motorcycle_Association1/views/forgotPassword.jsonC:/Users/zerov/OneDrive/Documents/CVMA/Media/cropped-Lucky7_512x512.png(source file)
Useful Resources: Check These Out!
To get a better handle on what's going on, we've been looking at these resources:
- Google Drive Sharing: https://support.google.com/drive/answer/2494822
- Experience Cloud Rich Text: https://help.salesforce.com/s/articleView?id=sf.networks_components_richtext.htm
- Salesforce CSP: https://developer.salesforce.com/docs/atlas.en-us.securityImplGuide.meta/securityImplGuide/csp_overview.htm
- Stack Overflow: Google Drive direct image link discussions
- Browser console error output (November 10, 2025)
Context: The Bigger Picture
This issue is part of a larger effort to integrate Google Drive with our Salesforce environment. Here’s some context:
- Epic #3: Resource Library (Knowledge Articles + Google Drive)
- Epic #12: Google Drive file integration (PDFs working, images not tested)
- Asset File Migration: Blocking Contact creation due to storage limits
- Architecture Decision: Option C Hybrid (Knowledge + Google Drive links)
Next Steps: Let's Get This Done!
Here's what we're planning to do next:
- [ ] User tests
<iframe>embed approach after manual publish. - [ ] If
<iframe>works: Document as solution, proceed with Asset File deletion. - [ ] If
<iframe>fails: Implement Static Resources fallback immediately. - [ ] Update our architecture documentation with findings.
- [ ] Create a migration guide with the proven solution.
Wrapping Up: Stay Tuned!
So, that's where we are with the Google Drive image issue in Experience Cloud. It’s a tough nut to crack, but we’re on it! We'll keep you updated as we make progress. Stay tuned for the next steps, and hopefully, we’ll have a solid solution soon!