03-May-2021 02:55
Hello,
I am developing an iRule, and I am stuck on a piece of code, where I should respond with a specific CSS iFile, which will substitute the backend resource.
Within the CSS file is referenced a JPG file, which itself references a JPG contained on an external website.
The piece of iRule code is the following:
if {[URI::basename [HTTP::uri]] ends_with ".css"} {
HTTP::respond 200 content [ifile get <ifile_name>.css]
}
I looked at the documentation, but I had no luck.
I am wondering if anybody knows, if it's possible to reference an iFile within the CSS code, in order to fetch an F5 internal resource, instead of relying to an external website which might or might not contain the JPG file.
Thanks a lot in advance
Solved! Go to Solution.
03-May-2021 03:52
Sorry, not sure if we can add ifile within ifile. We will keep this discussion open for others to comment.
But just a thought, why can't you look for an option to update current primary css file to add image file there. something like b64 encoded image?
https://stackoverflow.com/questions/17090571/is-there-a-way-to-set-background-image-as-a-base64-encoded-image
03-May-2021
03:12
- last edited on
21-Nov-2022
16:18
by
JimmyPackets
yes, you can reference css ifile. Import the css file on F5 and use below code
<ifilename> = example.css
switch -glob [string tolower [HTTP::uri]] {
"*/css" {HTTP::respond 200 content [ifile get <ifilename>] "Content-Type" "text/css"}
03-May-2021 03:39
Thanks Sanjay, but my question was different, I'll elaborate on it: within the referenced CSS iFile, is it possible to reference another iFile, which would contain a JPG ? If not, how can I approach this issue, and not rely on external resources?
Thanks for any reply
03-May-2021 03:52
Sorry, not sure if we can add ifile within ifile. We will keep this discussion open for others to comment.
But just a thought, why can't you look for an option to update current primary css file to add image file there. something like b64 encoded image?
https://stackoverflow.com/questions/17090571/is-there-a-way-to-set-background-image-as-a-base64-encoded-image
03-May-2021 04:02
Thanks Sanjay. I didn't think about that approach.
I have converted the image to Base64, and it looks like the solution is OK.
Thanks a lot for your input
03-May-2021 04:03
Glad I was of some help 🙂