Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
262 views
in Technique[技术] by (71.8m points)

javascript - Instagram - Bootstrap 3 carousel with instafeedjs

I am using instafeedjs to display the pictures on a site. I am trying to add Bootstrap 3 carousel by following link. - http://www.tutorialrepublic.com/codelab.php?topic=bootstrap&file=carousel-methods.
When I run the code it displays nothing.

   <script type="text/javascript">  
    var feed = new Instafeed({  

        get: 'tagged',
        tagName: '****',
        clientId: '*************',
        limit: 20,
        sortBy: 'most-recent',
        template: '<div class="item"><img src="{{image}}"/></div>',
        success: function (data) {
            $('.carousel').carousel({ interval: 3000 });
            for (var i = 0; i < $(data.data).size() ; i++) {
          $('.carousel-inner').append('<div class="item"></div>');
       $('.item').append('<div class="col-sm-2 instagram-  placeholder"><img  src=' + data.data[i].images.standard_resolution.url + ' class="img-responsive"></div>');
            }  
            $('.carousel').carousel('next');

            },
            after: function () {
            $('#instafeed > div:nth-child(1)').addClass('active');
      }

   });
    feed.run();
</script>

Here is the HTML:

  <div id="carousel" class="carousel slide" data-interval="false">
    <div class="carousel-inner" id="instafeed"></div>
 </div>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here is the code that supports carousel on loaded feeds. The number of image is limited the the value set by the instafeed property 'limit' and the carousel runs infinitely.

HTML

<html>
<head>
    <title>Example of Bootstrap 3 Carousel with Instafeed Instagram feeds - Ajith</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <script src="http://sriajith.info/blog/wp-content/uploads/2015/05/instafeed.min_.js"></script>
</head>

<body>
    <div class="bs-example">
        <div id="myCarousel" class="carousel slide" data-interval="3000" data-ride="carousel">
            <div class="carousel-inner" id="instafeed">
            </div>
        </div>
    </div>
</body>
</html> 

JavaScript

<script type="text/javascript">
    var feed = new Instafeed({
        get: 'tagged',
        tagName: 'ajith',
        clientId: '467ede5a6b9b48ae8e03f4e2582aeeb3',
        limit: 20,
        sortBy: 'most-recent',
        resolution: "low_resolution",
        template: '<div class="item"><img src="{{image}}"/></div>',
        after: function () {
            $('#instafeed > div:nth-child(1)').addClass('active');
        }
    });
    feed.run();
</script>

Find the working demo here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...