How to Generate a Public Image in Salesforce?
In order to use the image field feature in Merge Connect for Google File Types, you must use a public link for your image.
- Go to Files tab.

- Select the dropdown icon for your desired image.

- Select View File Details.

- In the file details page, you will need to find the ID for your file in the URL field.

- Select the Gear icon.

- Select Developer Console.

- Select Query Editor.
8. In the query editor paste the following query where the id from file detail page’s URL is the ContentDocumentId value, then select Execute:SELECT Id FROM ContentVersion WHERE ContentDocumentId = '[id from file detail page]' AND IsLatest = true

- Copy the ID from the query results.

- Select the Logs tab.

- Select Debug.

- Select Open Execute Anonymous Window.

- In the Enter Apex Code window paste the following code, where the cvid is the id from the query, and select Execute:
Id cvId = '[id from query]';
ContentDistribution newCD = new ContentDistribution();
newCD.Name = 'External Document Image';
newCD.ContentVersionId = cvId;
newCD.PreferencesAllowViewInBrowser = true;
newCD.PreferencesLinkLatestVersion = true;
newCD.PreferencesNotifyOnVisit = false;
newCD.PreferencesPasswordRequired = false;
insert newCD;
ContentDistribution finalCD = [SELECT ContentDownloadUrl
FROM ContentDistribution
WHERE Id = :newCD.Id
LIMIT 1];
System.debug('--- COPY THIS URL ---');
System.debug(finalCD.ContentDownloadUrl);
System.debug('---------------------');

- Open up the generated log.

- Look for a URL in the logs, this URL is the public link you can use for your URL field value for image merge field use in Merge Connect.
