Hot answers tagged

14

This should be possible: we do this in FinancialForce Accounting via the servlet.fileDownload URL that salesforce provides for downloading documents to include company logos on PDF financial documents. The trick is that any external URLs you want salesforce to make a HTTP(s) call to need to be defined under Setup > Security Controls > Remote Site Settings. ...


10

I don't have specific code to share, but if HTML5 is a possibility then converting the image to a Canvas tag might be able to do this. You can manipulate the canvas and then convert the result into a base64 string.


9

Are you sure the rich text field is visible to the site profile? It's not included in the regular list, you have to go to the site settings and access the profile from there where you can then check whether the field level security is good. I assume it is since you have the URL , but then I don't know why you can't access the image. Have you tried using ...


8

I'm not aware of a way to manipulate images within Apex. This would be beyond the capabilities of Apex. One approach however could be to push the uploaded image out to an external process to handle the resizing. After the file has been uploaded push the file to a third party web service using a apex call out and have the web service return the resized image. ...


8

Here's a (mostly) client-side version that should run on all modern browsers (NOTE: Modern does not include IE8 or lower). Does not use view state, and accepts any image type the browser does. Error checking is sparse, as this is only a demonstration. This uses a drag-and-drop interface, but you could also build a traditional file selector interface (not ...


8

I solved this in our org by changing the URL to the following: https://mydomain.my.salesforce.com/servlet/servlet.ImageServer?id=015a00000030EqL&oid=00D30000000X7qS&lastMod=1392744621000 Salesforce will automatically redirect this to: https://mydomain--c.na13.content.force.com/servlet/servlet.ImageServer?id=015a00000030EqL&oid=00D30000000X7qS&...


7

You can expose the image through a site. You only need to change the instance url by the site home page. Also, you need to establish the article as public. Site Profile Changes: Set field where image is placed as visible. Set Read permission to object where image is placed. Go to "Category Group Visibility Settings" section and set visibility to "All ...


7

Attachments are not public hence anybody receiving the email would need a login for your org to be able to see the images you're trying to send. One alternative would be to host the images elsewhere which will likely be faster, or you could upload the images as public documents in Salesforce as you can generate a public URL for documents so that they can be ...


7

Your community will have a URL prefix and you will need to add that prefix as well <img src="/urlpathprefix /resource/Icon_one" height="30" width="30"/> You can return this prefix using Netwrok Object record String urlpathprefix = [Select UrlPathPrefix from Network where Id =:Network.getNetworkId()].UrlPathPrefix Try prepending 'sfsites/c/' to you ...


6

I had a similar need recently and ended up using HTML 5 canvas for this purpose based on what joshbirk said. It turned out to be pretty straight forward. Here is a link to working demo: http://free-12415f14c3a-124e539428a-12ea33928a3.mysandbox.cs11.force.com/ResizeImage and the github link https://github.com/bkhakurel/ImageResizeApex


6

Sure, <apex:image> tag or plain old <img>. It cannot be an image from static resources though. If you want to use image hosted in your salesforce, best would be to upload it to Documents and tick the "externally available image". And then remember to use full path: https://{instance id}.salesforce.com/servlet/servlet.ImageServer?id={document id}&...


6

Yes, you can. I've done it. The (undocumented) trick is that you need to have Remote Site Setting records setup for the domains where the external URLs are hosted.


6

eid is a custom object, the "entity ID". Presumably, you could use this to view an instance of your record. feoid is the "field entity ID". This describes the field that the content is stored in. You can see this value when you're looking at the field in the Setup screen. refid is an ID of the type ContentReference. We're not able to describe this object, ...


6

You might be able to use the OAuth accessToken in a cookie with the HTTP GET request to servlet/rtaImage depending on the scope you requested when getting it. I believe you will need to use the full or web scopes to then make web requests or use frontdoor.jsp. See: Scope Parameter Values Use OAuth 2.0 Tokens to login to Salesforce.com The cookie will ...


6

You will need to check the Content-Type of attachment loaded String contenttype=Attachment.contenttype; if(contenttype=='image/jpeg' || contenttype=='image/png' || contenttype=='image/gif' || contenttype=='image/jpg' ){ }


5

The FeedItem has a field called RelatedRecordId which is defined as: ID of the ContentVersion object associated with a ContentPost. This field is null for all posts except ContentPost. For example, set this field to an existing ContentVersion and post it to a feed as a FeedItem object of TypeContentPost. If you right click on the download link for the ...


5

Where did you get your accessToken from? If you used OAuth to establish the session then you will need to have the web OAuth scope to use the sessionid for what is essentially a screen scraping web request. Having the api scope would be sufficient for the Partner API, but for for mocking UI requests. Other than that, as you have found, you need to put the ...


5

open document tab,and image what u want to display,right click on image copy and paste it in <apex:image > <messaging:emailTemplate subject="vf template" recipientType="Contact" > <messaging:plainTextEmailBody > Congratulations! This is your new Visualforce Email Template. <apex:image url="sahitya0907-dev-ed--c.ap2....


5

When a user uploads images in RichTextArea field salesforce creates this kind of link and ContentReference is maintained by Salesforce internally, which is not accessible by an user using the refid. <img src="https://c.{instance}.content.force.com/servlet/rtaImage?eid=a0yxxxxx&amp;feoid=00Nxxxx&amp;refid=0EMxxxxx" alt="Inline images 1" width="478"...


5

Try this format <apex:image url="/sfc/servlet.shepherd/version/download/[DOWNLOADID]"/>. How to get the DOWNLOADID? Open the File, you will get a screen as below. Hover on the download link, you will get the DOWNLOADID as highlighted. Replace [DOWNLOADID] with the ID of the ContentVersion record you want to display. Example: <apex:image url="/...


5

You need to specify some content and/or a height in order for this to work. I tweaked your code slightly to display the image as a background image: <div style="{!'position: relative; height: 30vh; background:' + v.backgroundColor + ' url(' + v.backgroundImageURL +') no-repeat;background-position: center;background-size: cover;'}"> </div>


5

You would normally upload a ZIP file, and use it in the manner described in the docs: import TRAILHEAD_CHARACTERS from '@salesforce/resourceUrl/trailhead_characters'; // ... einsteinUrl = TRAILHEAD_CHARACTERS + '/images/einstein.png'; Loading a dynamic resource name directly is not supported; this is because the compiler will verify the resource name ...


4

Obviously you can specify the height and width in an image tag in a VF page, but there is nothing built in to Salesforce that can do the image manipulation/processing that you are seeking. You might want to check out the AppExchange, but in my scan I didn't see anything there. Here is the idea to add Apex Image Processing. Vote it up. As @Killian said, ...


4

This will smell horrendous but I'm guessing you want HTML in the portal header for good reason ;-) Upload it as a Static Resource and use JavaScript UserContext.siteUrlPrefix to resolve the path: <script type="text/javascript"> document.write( "<img " + "src='" + UserContext.siteUrlPrefix + "/resource/yourImagePng'" + "/>" ); &...


4

You need to pass organization id while referring externally available image in your email document and url is also bit different which you use while referring the document. <messaging:emailTemplate subject="Details -" recipientType="User" relatedToType="Evaluation__c"> <messaging:plainTextEmailBody> Congratulations! This is your new ...


4

Figured it out after debugging a bit more. Blob img; public Object getImg () { List<ContentVersion> bodyList = [SELECT VersionData FROM ContentVersion WHERE ContentDocumentId='insert your id']; img = (Blob) bodyList[0].get('VersionData'); return EncodingUtil.base64Encode(img); } All I had to do was to typecast the Object as Blob and ...


4

Keep in mind, that FTP is just a way of uploading your assets to a web server. Not a specific web server type. SFMC uses Akamai for serving images, and being a CDN, it offers an optimised way of doing so. If you use a regular web server, e.g. Apache, this will only have a single location/IP, and can indeed suffer from poor throughput - proving to be a ...


3

You are already in a Visualforce expression because of the outer url="{! ... }" so should able to use simple string concatenation: <apex:image url="{! URLFOR($Resource.Apex_Icons, Object_A.Icon__c + '.png') }"/>


3

We've run similar upload forms through security review and haven't had any problems. The security scanner is the basis for most of their concerns. As long as your working on the same domain browsers enforce pretty strict access policies that keep salesforce users safe from cross-domain access exploits.


3

Not sure how big the image you're wanting to render is, but if is simply an icon you could first consider a simple formula field that renders an image in the details panel for the case that is in context i.e. formula:IF(IsClosed,IMAGE("url for image if closed","case is closed"),IMAGE("url for case open","case is still open")) If you do need to use a VF ...


Only top voted, non community-wiki answers of a minimum length are eligible