
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Apropos helps your site serve up the appropriate image for every visitor. Serving multiple versions of an image in responsive and/or localized web sites can be a chore, but Apropos simplifies and automates this task. Instead of manually writing a lot of CSS rules to swap different images, Apropos generates CSS for you based on a simple file naming convention.
Apropos requires Ruby 1.9 or greater.
Add this line to your application's Gemfile:
gem 'apropos'
And then execute:
$ bundle
Or install it yourself as:
$ gem install apropos
Apropos depends on Compass, so make sure you have that installed and configured in your project.
There are many tools and techniques for using responsive images. What makes Apropos different? A few key principles:
srcset
, require unnecessary extra downloads, which CSS classes and media queries avoid.It's easy to get up and running with Apropos' basic configuration. Here's a sample stylesheet:
// Put this in a .sass (or .scss) file, such as application.css.sass
// Substitute with your own breakpoint names and sizes
$apropos-breakpoints: (medium, 768px), (large, 1024px)
@import "apropos"
.hero
// Use hero.jpg as the background of this element, and load any image
// variants that exist. If you use $generate-height: true, the function
// will also generate height definitions based on the height of each
// image (except dpi variants, since you want to display those at the
// original dimensions).
+apropos-bg-variants('hero.jpg', $generate-height: true)
// Customize other background styles
background-size: auto 100%
background-position: 50%
With that configuration set up, you can include any set of variants on your image with a simple file naming convention:
# File listing e.g. app/assets/images:
hero.jpg
hero.medium.jpg
hero.large.jpg
hero.2x.jpg
hero.2x.medium.jpg
hero.2x.large.jpg
In this example, hero.jpg
would be your base image, most likely a mobile version. hero.medium.jpg
would be swapped in at the 768px breakpoint, and hero.large.jpg
would be swapped in at 1024px. On a high-dpi device, hero.2x.jpg
, hero.2x.medium.jpg
, and hero.2x.large.jpg
would be used instead. Note that the order of the file extensions doesn't matter; hero.2x.medium.jpg
and hero.medium.2x.jpg
work exactly the same.
You can customize Apropos' breakpoints as shown above, and you can also customize the definition of the "high dpi" variant:
// The default extension name is "2x", we're overriding to use "hidpi"
$apropos-hidpi-extension: "hidpi"
// The default ratio is 1.75 (or 168 dpi), but here we're overriding that
$apropos-hidpi-query: "(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)"
@import "apropos"
If you want to do more advanced configuration like adding variants for localization, you can customize Apropos in Ruby.
For some projects, it makes sense to only use high dpi images. If most of your visitors use high dpi devices, you can use fewer images and omit 1x assets. In fact, even for 1x devices you may be able to use higher compression rates on 2x assets that are scaled down. This also means your generated CSS only needs roughly half as many media queries. You can switch Apropos into "high dpi only" mode, where it will generate CSS definitions with halved heights and not output high dpi media queries, with the following config line:
# Place this in a Ruby configuration file, e.g. Compass config or Rails initializer
Apropos.hidpi_only = true
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Before any changes are merged to master, we need you to sign a very simple Individual Contributor Agreement (Google Form).
© 2013 Square, Inc.
FAQs
Unknown package
We found that apropos demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.