Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant overwrite template with filter transform or render #743

Open
kiwo12345 opened this issue Jun 29, 2022 · 1 comment
Open

Cant overwrite template with filter transform or render #743

kiwo12345 opened this issue Jun 29, 2022 · 1 comment

Comments

@kiwo12345
Copy link

kiwo12345 commented Jun 29, 2022

I am trying to change the template depending if its a image or video but it doesnt seem to work, it just uses the template provided when calling the function

<script src="https://cdn.jsdelivr.net/gh/stevenschobert/instafeed.js@2.0.0rc1/src/instafeed.min.js"></script>
<div class="instagram-module" id="instafeed"></div>

<script type="text/javascript">
    var feed = new Instafeed({
        get: 'user',
        target: 'instafeed',
        limit: 10,
        template: '<a class="instagram-link" href="{{link}}" target="_blank" rel="noopener"><figure class="instagram-figure"><video controls loop><source src="' + image.model.media_url + '" type="video/mp4"/></video><figcaption class="instagram-caption" >{{caption}}</figcaption></figure></a>',
        resolution: 'low_resolution',
        accessToken: 'token',
        filter: function(image) {

            if (image.type == 'image' ) {
                image.template = '<img src="' + image.image + '" />';
            } else {
      
                image.template = '<video controls loop><source src="' + image.model.media_url + '" type="video/mp4"/></video>';
            }
            return true;
        }
    });
    feed.run();
</script>
@emreond
Copy link

emreond commented Jan 26, 2023

Did you able to solve this? I need to also write an if check inside template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants