How can you refer to a hosted image file inside a CSS file?

Posted by jquerijero on 07-Jan-2015 17:21

I uploaded an image using the Hosted File feature. If I need to refer to this image inside a CSS (ex. background-image: url(...)), what is proper way of specifying the URL.

Or is there a more standard way of doing this?

All Replies

Posted by matman on 08-Jan-2015 02:40

I'm not sure if this solution works with other ways of implementing CSS in Rollbase, but you could do the following. Inside your Application header and footer, add:

<style>	
	body {
		background-image: url('{!#HOSTED_FILE.118978515}');
	}
</style>

Rollbase will then convert the merge token to a link, which will be used by the CSS. Hope I could help you out this way!

Posted by jquerijero on 08-Jan-2015 17:48

We are trying to change the Pacific Rollbase logo. There will be a delay before the in-page script is run, so the Pacific Rollbase logo will stay for a bit on the screen before being replaced.

Posted by matman on 09-Jan-2015 02:56

Ah I see, then I think the following would be better suited for you.

1. Create a new .CSS file.

2. Enter the following:

/* ROLLBASE DEFAULT CSS */
@import url("https://www.rollbase.com/prod1/css/rbtheme.css?v=3.1.3.0");

.pacific-logo {
	background-image: url("https://www.rollbase.com/storage/servlet/Image?c=108169344&fileName=938196161538943077.png&contentType=image%2Fpng&suggestedName=test.png");
	width: 237px;
	height: 34px;
	margin-left: 8px;
	align: left;
	float: left; 
}

3. Replace the url() of background-image with your hosted file URL. This is the URL that points to the direct location of your image, not the token

4. Upload this .CSS file to your hosted files.

5. Go to Settings > Administration Setup > Account Settings. In the "Appearance" section, click on the "CSS Stylesheet" dropdown. Select your uploaded .CSS stylesheet.

6. Go back to your application and check if everything went correctly.

Please note: The CSS file imports the Rollbase stylesheet. You must change this URL when Rollbase is updated, as a new, updated version of the stylesheet will most likely be available. Also, I'm not sure if this is a really great solution if you want to distribute your application to multiple customers. (I can't really think of a better solution right now.)

Posted by jquerijero on 12-Jan-2015 15:03

It sort of works. Since the URL is a calculated string, the specified value doesn't carry over to new install/ new tenant.

We decided to hijack the image file and will just be part of our install process.

This thread is closed