Skip to content

Commit

Permalink
Added image examples
Browse files Browse the repository at this point in the history
  • Loading branch information
samdutton committed Jan 6, 2015
1 parent 01b79d1 commit 8439412
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pictureart/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

var img = document.querySelector('img');
var imgSrc = document.querySelector('#imgSrc');
var imgNaturalWidth = document.querySelector('#imgNaturalWidth');
var imgWidth = document.querySelector('#imgWidth');

var dpr = document.querySelector('#devicePixelRatio');
var viewportWidth = document.querySelector('#viewportWidth');
var availableWidth = document.querySelector('#availableWidth');

function displayData(){
imgSrc.innerHTML = '<a href="' + img.currentSrc + '">' +
img.currentSrc.replace(/^.*[\\\/]/, '') + '</a>';
imgNaturalWidth.textContent = img.naturalWidth;
imgWidth.textContent = img.width;
dpr.textContent = window.devicePixelRatio;
viewportWidth.textContent = document.documentElement.clientWidth;
availableWidth.textContent = window.screen.availWidth;
}

img.onload = window.onresize = displayData;

// in case image already loaded -- is there a better way?
displayData();
Binary file added pictureart/large.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pictureart/medium.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pictureart/small.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions sizeswvalues/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

var img = document.querySelector('img');
var imgSrc = document.querySelector('#imgSrc');
var imgNaturalWidth = document.querySelector('#imgNaturalWidth');
var imgWidth = document.querySelector('#imgWidth');

var dpr = document.querySelector('#devicePixelRatio');
var minimumWidth = document.querySelector('#minimumWidth');
var viewportWidth = document.querySelector('#viewportWidth');
var availableWidth = document.querySelector('#availableWidth');

function displayData(){
imgSrc.innerHTML = '<a href="' + img.currentSrc + '">' +
img.currentSrc.replace(/^.*[\\\/]/, '') + '</a>';
imgNaturalWidth.textContent = img.naturalWidth;
imgWidth.textContent = img.width;
dpr.textContent = window.devicePixelRatio;
minimumWidth.textContent = img.width * window.devicePixelRatio;
viewportWidth.textContent = document.documentElement.clientWidth;
availableWidth.textContent = window.screen.availWidth;
}

img.onload = window.onresize = displayData;

// in case image already loaded -- is there a better way?
displayData();
27 changes: 27 additions & 0 deletions srcsetwvalues/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

var img = document.querySelector('img');
var imgSrc = document.querySelector('#imgSrc');
var imgNaturalWidth = document.querySelector('#imgNaturalWidth');
var imgWidth = document.querySelector('#imgWidth');

var dpr = document.querySelector('#devicePixelRatio');
var minimumWidth = document.querySelector('#minimumWidth');
var viewportWidth = document.querySelector('#viewportWidth');
var availableWidth = document.querySelector('#availableWidth');

function displayData(){
imgSrc.innerHTML = '<a href="' + img.currentSrc + '">' +
img.currentSrc.replace(/^.*[\\\/]/, '') + '</a>';
imgNaturalWidth.textContent = img.naturalWidth;
imgWidth.textContent = img.width;
dpr.textContent = window.devicePixelRatio;
minimumWidth.textContent = img.width * window.devicePixelRatio;
viewportWidth.textContent = document.documentElement.clientWidth;
availableWidth.textContent = window.screen.availWidth;
}

img.onload = window.onresize = displayData;

// in case image already loaded -- is there a better way?
displayData();

0 comments on commit 8439412

Please sign in to comment.