I am using instafeed.js to show my latest instagram images in my website. But by default, image links are opened in same window. This is the JS code: https://github.com/stevenschobert/instafeed.js/blob/master/instafeed.js more information: http://instafeedjs.com
I tried to open links in a new window by using this trick:
<script>
$(function(){
$("#instafeed a").attr("target","_blank");
});
</script>
But this trick is not working in this situation.
Any Solution? Thanks.
The best way to do it, would be to use the template
option:
var feed = new Instafeed({
template: '<a href="{{link}}" target="_blank"><img src="{{image}}" /></a>'
// other settings...
});
You shouldn't need to modify the source file directly.
For more information on how templates work, check the documentation on templating.
I update the links in the after function
jQuery(document).ready(function($){
var loadButton = $('#load-more');
var feed = new Instafeed({
get: 'user',
userId: xxx,
accessToken: 'xxxx',
limit:160,
after: function() {
$("#instafeed a").attr("target","_blank");
// disable button if no more results to load
if (!this.hasNext()) {
loadButton.attr('disabled', 'disabled');
}
}
});
$('#load-more').on('click', function() {
feed.next();
});
feed.run();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With