Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

New picturefill.js doesn't work with SmellsLikeBakin

Looks like the way picturefill.js works is different now than when the video Flexible Images Part Two: Raster Images was made.

Just a heads up if anyone should search on this forum in regards to this:

The picturefill.js in the project files works. A new one downloaded from github will not.

2 Answers

Looked at their current example; changed my div's to span's for the DOM object, also I moved the "meta viewport..." tag in front of the scripts in the header. Now the current version works famously.

Nice! So it's now:

<span data-picture data-alt="Bacon Me Crazy">
<span data-src="external/imgs/bacon-small.jpg"></span>
<span data-src="external/imgs/bacon-medium.jpg" data-media="(min-width:400px)"></span>
<span data-src="external/imgs/bacon-large.jpg" data-media="(min-width:800px)"></span>
<span data-src="external/imgs/bacon-extralarge.jpg" data-media="(min-width:1000px)"></span>
<span data-src="external/imgs/bacon-extralargejpg" data-media="(min-width:1000px) and (min-device-pixel-ratio: 2.0"></span>


<!-- Fallback content for non-JS browsers. Same img src as the initial, unqualified source element. -->
<noscript>
<img src="external/imgs/bacon-small.jpg" alt="Bacon Me Crazy">
</noscript>
</span>

Why did you move the meta viewport tag? Just for syntax purposes?

Just following the example, just a lucky guess. But now, I suspect that the PictureFill script references the viewport and that a script can only access things that have been declared already, hence the meta viewport tag goes before the script.

But it works for me with the meta tag after the scripts?

Nick Pettit
STAFF
Nick Pettit
Treehouse Teacher

Thanks for pointing that out, Thomas MacFarlane! I've added some information about this to the teacher notes section of that video.

You're welcome! :)