Dev Depot: Ramping Up for Retina — Retinajs.com

2013 could be considered the year of the tablet as an increasing number of consumers are turning to the powerful but portable form factor as their computing platform of choice — combining clear, sharp graphics with impressive multimedia capabilities to become a preferred viewing portal for everything from web pages to first-run movies.

While this power is a boon to users, the clarity of these high resolution displays — which can operate at 384ppi (compared to a standard ‘desktop’ display or TV at 72ppi), can leave legacy graphics looking lackluster and of a lower quality than they really are — a situation that is driving designers to seek out cross-platform image delivery techniques.

The JavaScript solution is simple and easy to add to just about any site via a helper script that automatically replaces the images on a web page with high-resolution variants (if they exist).

According to its publisher, Imulus, retina.js (www.retinajs.com) is an open source script that makes it easy to serve high resolution images to devices that employ Retina displays, such as Apple’s iPad, providing a path for bringing these images to your site.

It is a simple enough concept, Imulus explains: When your users load a page, retina.js checks each image on the page to see if there is a highresolution version of that image on your server. If a high-resolution variant exists, the script will swap in that image in-place.

Of course, retina.js assumes that Apple’s specified high-resolution modifier (@2x) is being used to denote high-resolution image variants on your server. For example, source code to call an image to a web page might looks like this: <img src=”image.png”>, with the retina.js script then checking the server for an alternative graphic, “image@2x.png,” existing in the same directory.

Using retina.js is easy, with implementations for JavaScript and LESS.

The JavaScript solution is simple and easy to add to just about any site via a helper script that automatically replaces the images on a web page with high-resolution variants (if they exist). Simply download the retina.js script and place it on your server, including a call to it at the bottom of your page template, before the closingtag, such as: <script src=?/scripts/retina.js?></script>.

The LESS process involves a bit more, however, with the LESS CSS mixin acting as a helper for applying high-resolution background images to the stylesheet. Provide it with an image path and the dimensions of the original-resolution image and then the mixin will automatically create a media query specifically for Retina displays — changing the background image for the selector elements to use the high-resolution (@2x) variant and applying a background-size of the original image in order to maintain proper dimensions — an important step to avoid double-sized images. Implementation involves downloading the .at2x() mixin as part of retina.less and then importing or including it into the LESS stylesheet, applying it to elements of your choice by calling the .at2x() mixin anywhere instead of using the backgroundimage CSS; using the syntax .at2x(@path, [optional] @width: auto, [optional] @height: auto); within CSS.

Users of Ruby on Rails or any other framework embedding hash values in asset URLs based on its content, such as “/images/image-{hash1}.jpg,” encounter problems with the different hash value that high-resolution versions would have, thus automatic detection methods fail because there is no way for the retina.js script to know beforehand what the high-resolution image’s hash value would be, without server side help. Fortunately, www.github.com/imulus/retinajs offers Ruby workaround examples.

Altogether, retina.js is an intriguing option for solving the problems of serving both high resolution and standard resolution images seamlessly and side by side.

Related:  

Copyright © 2024 Adnet Media. All Rights Reserved. XBIZ is a trademark of Adnet Media.
Reproduction in whole or in part in any form or medium without express written permission is prohibited.

More Articles

profile

'Traffic Captain' Andy Wullmer Braves the High Seas as Spirited Exec

Wullmer networked and hobnobbed, gaining expertise in everything from ecommerce to SEO and traffic, making connections and over time rising through the ranks of several companies to become CEO of the mobile business arm of TrafficPartner.

Alejandro Freixes ·
opinion

To Cloud or Not to Cloud, That Is the Question

Let’s be honest. It just sounds way cooler to say your business is “in the cloud,” right? Buzzwords make everything sound chic and relevant. In fact, someone uninformed might even assume that any hosting that is not in the cloud is inferior. So what’s the truth?

Brad Mitchell ·
opinion

Upcoming Visa Price Changes to Registration, Transaction Fees

Visa is updating its fee structure. Effective April 1, both the card brand’s initial nonrefundable application fee and annual renewal fee will increase from $500 to $950. Visa is also introducing a fee of 10 cents for each settled transaction, and 10 basis points — 0.1% — on the payment volume of certain merchant accounts.

Jonathan Corona ·
opinion

Unpacking the New Digital Services Act

Do you hear the word “regulation” and get nervous? When it comes to the EU’s Digital Services Act (DSA), you shouldn’t worry. If you’re complying with the most up-to-date card brand regulations, you can breathe a sigh of relief.

Cathy Beardsley ·
opinion

The Perils of Relying on ChatGPT for Legal Advice

It surprised me how many people admitted that they had used ChatGPT or similar services either to draft legal documents or to provide legal advice. “Surprised” is probably an understatement of my reaction to learning about this, as “horrified” more accurately describes my emotional response.

Corey D. Silverstein ·
profile

WIA Profile: Holly Randall

If you’re one of the many regular listeners to Holly Randall’s celebrated podcast, you are already familiar with her charming intro spiel: “Hi, I’m Holly Randall and welcome to my podcast, ‘Holly Randall Unfiltered.’ This is the show about sex, the adult industry and the people in it.

Women In Adult ·
trends

What's Hot Now: Leading Content Players on Trending Genres, Monetization Strategies

The juggernaut creator economy hurtles along, fueled by ever-ascendant demand for personality-based authenticity and intimacy — yet any reports of the demise of the traditional paysite are greatly exaggerated.

Alejandro Freixes ·
opinion

An Ethical Approach to Global Tech Staffing

One thing my 24-year career as a technologist working to support the online adult entertainment industry has taught me about is the power of global staffing. Without a doubt, I have achieved significantly more business success as a direct result of hiring abroad.

Brad Mitchell ·
opinion

Finding the Right Payment Partner

Whenever I am talking with businesses that are just getting started, one particular question comes up a lot: “How do I get a merchant account?” It’s a simple question, but it has a complicated answer.

Jonathan Corona ·
opinion

The Taxman Cometh for Every Business

February may be the month of romance, but it is also a time when we need to think about something that inspires very little love: taxes. April is not far away, and the taxman is always waiting. This year, federal and most state income taxes are due Monday, April 15.

Cathy Beardsley ·
Show More