1
After much search for a very simple image gallery I ended up finding the Responsiveslides.js which is not only quite simple, but also works satisfactorily in smartphones (even if the latter does not recognise Gestures for slide exchange - but that’s another story).
However, like many gallery/slide plugins, the Responsiveslides works with the existing and/or predefined HTML markup and it is precisely in this that I seek adaptation or, suddenly, suggestion of alternative because, at least initially, the images used will be hosted in the Imgur and consumed through your API.
I even found an Issue in the Github repository of someone’s project with similar intent to mine that went beyond an initial implementation, but also failed to succeed.,
And this limitation is bad in terms of performance because it requires that the images that will be part of the gallery are previously loaded, hindering or even preventing the Lazy Load theirs.
As requested, the importing part of the current code:
<article id="uCSg1">
<h3 role="heading"></h3>
<figure class="cover">
<img src="http://i.imgur.com/Ik3yGs8.jpg">
</figure>
<section class="permalink">
<div class="separator"></div>
<p>Posted on Sunday, 9 December with 1 note.</p>
<p>Reblog This Post.</p>
</section>
</article>
This block repeats as many times as there are articles on the page. The element <article>
has the same ID as the album ID. In this example, the album is that.
The image in the element <figure>
is the album cover image, set in the album settings by the Imgur interface. As this album in question is not mine, I used the first image even.
In Javascript:
$( document ).ready(function() {
$( 'article' ).each( function() {
buildGallery( $( this ) );
});
});
function buildGallery( article ) {
$.ajax({
url: 'https://api.imgur.com/3/album/' + article.attr( 'id' ),
type: 'get',
headers: {
Authorization: 'Client-ID 123456'
},
dataType: 'json',
success: function( response ) {
if( response.success ) {
// Monta a galeria/slides
}
}
});
}
The data model used is the Album and in that case produces as a response this JSON
The API Imgur requires authentication with an access key which was purposely falsified here. However the registration for new keys is free.
Bruno: and what is your question? how to adapt to use Mgur images? how do you import Mgur images? via iframe? can show an example of the images/html you want without the responsiveslides? will receive the URL via json?
– Sergio
This question is a more detailed and more targeted rewording than I had posted in the English OS. The question is exactly what it looks like, that is, adapt or extend, perhaps, Responsiveslides so that it uses an external data-source, in JSON, result of the consumed API (which I already have in operation) so that the images are loaded on demand and not all at once, in the load page.
– Bruno Augusto
Bruno, can you put the code you already have? So I can test and answer your question with a solution.
– Sergio
Although this has exponentially increased the complexity of stack, done. ;)
– Bruno Augusto