Skip to content

Instantly share code, notes, and snippets.

@jafow
Last active January 14, 2016 02:35
Show Gist options
  • Save jafow/13bb3c1e94a0c38eeaf2 to your computer and use it in GitHub Desktop.
Save jafow/13bb3c1e94a0c38eeaf2 to your computer and use it in GitHub Desktop.
placing an avatar and image feed
$( document ).ready( function () {
$.getJSON("#dataobject", (data) => {
let imgArray = matchElements(data)(/(?:scontent)/);
//place and style the user avatar thumbnail
placeAvatar(".img-thumbnail", imgArray[0]);
//display the user's feed
$( ".img-display" ).html("<img src='" + imgArray[1] + "'/>");
});
});
});
//Places and styles the user avatar;
const placeAvatar = (selector, src) => {
$(selector).attr("src", src).css({height: "28px", width: "28px"});
//IG doesn't style the border radius of the <img> itself. Rather they style the parent <a> tag border radius.
$( ".avatar" ).css({borderTopLeftRadius: "50%", borderTopRightRadius: "50%"});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment