Skip to content

Instantly share code, notes, and snippets.

@jondashkyle
Last active August 29, 2015 14:17
Show Gist options
  • Save jondashkyle/dddcf6ed4a4e8bcc3def to your computer and use it in GitHub Desktop.
Save jondashkyle/dddcf6ed4a4e8bcc3def to your computer and use it in GitHub Desktop.
src img

Attribute That Shit

A drop-in solution for crediting the sources of your un-attributed image blog. Uses a modified version of Jarred Bishop’s handy bookmarklet src img.

To use, copy and paste the code below before the </head> tag of your page. If you're using Tumblr, you can locate this by navigating to your Dashboard → Customize (right column) → Edit HTML (up top).

In use on http://blog.hrstudioplus.com

<script type="text/javascript">
var srcOptions = {
attr: 'data-src-show'
}
function srcClick(e) {
if (e.target && e.target.hasAttribute(srcOptions.attr)) {
srcShow()
}
}
function srcShow() {
var sir = document.createElement('script')
sir.setAttribute('src','http://cdnjs.cloudflare.com/ajax/libs/require.js/0.26.0/require.min.js');sir.setAttribute('type','text/javascript')
document.getElementsByTagName('head')[0].appendChild(sir)
var sib= document.createElement('script')
sib.setAttribute('src','http://jarred.github.com/src-img/js/app/bookmarklet.js?version=0.66')
sib.setAttribute('type','text/javascript')
document.getElementsByTagName('head')[0].appendChild(sib)
}
document.addEventListener('DOMContentLoaded', function() {
document.getElementsByTagName('body')[0].addEventListener('click', srcClick)
})
</script>
<style>
.show-src {
cursor: pointer;
color: #808080;
font-weight: normal;
font-size: 12px;
line-height: 1;
position: fixed;
bottom: 0;
right: 0;
padding: 25px;
z-index: 9;
}
</style>
<div class="show-src" data-src-show>?</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment