GithubHelp home page GithubHelp logo

slimresponse's Introduction

SlimResponse

Effortless reponsive images powered by ImageResizer and Slimmage.js

Dual-licensed by Imazen under the MIT and Apache licenses.

Install-Package Imazen.SlimResponse

(Well, actually, you may also need to run Install-Package HtmlAgilityPack) The current release forgot to specify that dependency.

###What does it to?

SlimResponse looks through outgoing HTML for <img> tags with a slimmage class applied, such as

<img class="slimmage" src="image.jpg?width=150" />

<img class="thisclass slimmage thatclass" src="image.jpg?width=150" />

or for "slimmage=true" in any image URL

<img src="image.jpg?width=150&slimmage=true" />

Slimmage requires "width=[number]" be present in the URL. This value specifies the image size when javascript is disabled, but is modified by slimmage.js under normal circumstances.

It then adds the appropriate markup to allow slimmage.js to turn them into responsive images.

Requirements

Spin it up quickly for a test!

  • Use WebMatrix or VisualStudio (Open Web Site) and fire it up on the "www"-folder, that's all!

Notes & Caveats

  • This parses all outgoing HTML. This may increase CPU usage slightly.
  • Outgoing HTML is only modified if a responsive image is present.
  • SlimResponse may mess up invalid HTML even further during parsing/serialization.
  • If you're only using responsive images in limited situations, an HTML helper that spits out slimmage markup may be more appropriate.
  • SlimResponse does not include the slimmage.js javascript file, that's your responsibility.

Your web.config file must have both ImageResizer and SlimResponse installed

<?xml version="1.0"?>
<configuration>
  <system.web>
    <httpModules>
      <!-- This is for IIS5, IIS6, and IIS7 Classic, and Cassini/VS Web Server-->
      <add name="ImageResizingModule" type="ImageResizer.InterceptModule"/>
      <add name="SlimResponseModule" type="Imazen.SlimResponse.SlimResponseModule, Imazen.SlimResponse"/>
    </httpModules>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <!-- IIS7+ Integrated mode -->
      <add name="ImageResizingModule" type="ImageResizer.InterceptModule"/>
      <add name="SlimResponseModule" type="Imazen.SlimResponse.SlimResponseModule, Imazen.SlimResponse"/>
    </modules>
  </system.webServer>
</configuration>

Thanks to esn303 for creating ImageResizer.ResponsivePresets and being the inspiration behind this project.

This project is open to collaboration. Fork. Push. Innovate.

slimresponse's People

Contributors

chrispont avatar idisposable avatar lilith avatar marcstoecker avatar patgaunt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slimresponse's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.