Skip to content
This repository has been archived by the owner on Dec 30, 2019. It is now read-only.

Added --inlineImages option to embed images. #32

Merged
merged 2 commits into from
Jul 10, 2012

Conversation

gcoop
Copy link
Contributor

@gcoop gcoop commented Jun 23, 2012

Have enabled it by default, which may not be suitable.

I did have to make one change to core.js so .on would have access to the file path that was being processed, because I needed to get the image data relative to the .css file. I couldn't think of another way to do it.

Added lint rule and tests for both compile and linting.

@fat
Copy link
Contributor

fat commented Jun 24, 2012

this is so amazing. I'm going to try to review this tomorrow morning, but it looks great! Thanks :)

@gcoop
Copy link
Contributor Author

gcoop commented Jun 24, 2012

Cool I think the only change will be to disable it by default that way you'll need to supply the option to have the images embeded.

No rush I can use it in my project as is :)

Sent from my iPhone

On 24 Jun 2012, at 04:24, Jacob Thorntonreply@reply.github.com wrote:

this is so amazing. I'm going to try to review this tomorrow morning, but it looks great! Thanks :)


Reply to this email directly or view it on GitHub:
#32 (comment)

var props = toCSS.apply(this, arguments)

// do we have a url here?
if (/url\(([a-zA-Z\"\'.]+)\)/.test(props)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe let's just simplify this to: /url\(/.test(props) or something along those lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, brought up a bug where it wasn't embedding if images links included paths (../sprite.png etc). Have added test for this now.

Did bring up another issue where the tests were failing because the relaxed regex test was picking up font-face src in blog.css and there is no file to embed. I just removed the @font-face declaration from blog.css hope that's ok?

@fat
Copy link
Contributor

fat commented Jun 28, 2012

few little things, but mostly looks good - thanks again!

@gcoop
Copy link
Contributor Author

gcoop commented Jun 28, 2012

Cool looks good I will make those changes on the weekend probably.

… added another test for embedding images that include paths.
@travisbot
Copy link

This pull request passes (merged aa6b815 into 2d3d018).

@gcoop
Copy link
Contributor Author

gcoop commented Jul 8, 2012

@fat any ideas if/when this will get merged into master?

@thezoggy
Copy link

https://github.com/GoalSmashers/enhance-css

i really like how they do their inline images.. really flexible to just add ?embed after the images you want it to base64. also they have an option to spit out a non embeded version for pre ie8 support..

@gcoop
Copy link
Contributor Author

gcoop commented Jul 10, 2012

Looks good. Not something I will need. I have about 150-200k worth on encoded images, defined in one file separate from the main stylesheet. Anything I need to encode I add to this stylesheet and my build script enables the inlineImages option only on this stylesheet (using recess) and it copies the original to a built folder (to serve to ie8). This is a benefit for two reasons a) any css changes don't cause the user to download unchanged encoded images. My sprites rarely change my css changes a lot. Second I async the stylesheet in at the bottom of the page with some js. Standard css link's in the head cause most browsers to block rendering until complete. Seeing as the sprites are non-critical this makes sense.

Enhance looks good, there would be no downsides in using it, but there is also no real benefit for my specific use case :)

fat added a commit that referenced this pull request Jul 10, 2012
Added --inlineImages option to embed images.
@fat fat merged commit 8f0ce60 into twitter-archive:master Jul 10, 2012
@fat
Copy link
Contributor

fat commented Jul 11, 2012

sorry @gcoop got a bit caught up with other things. The changes all look good - just pushed out a new version 1.1.0 which has this in it :)

@thezoggy
Copy link

btw readme needs to be updated to reflect this option

@thezoggy
Copy link

if i do --inlineImages true with --compile > whatever.css the file ends up being empty. so it's slightly different than the other options. should note in the docs that this function option only works with jpg/jpeg

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants