codemonauts / craft-instagram-feed

Craft CMS plugin to receive Instragram feed data as variable in templates
MIT License
27 stars 7 forks source link

Query for non-videos in Twig #50

Closed ljclark closed 2 years ago

ljclark commented 3 years ago

This is more of a question - I'm trying to query for all non-video format posts, something like the following:

{% set instaFeed = craft
    .instagram
    .isVideo(false)
    .getFeed()[: 6]  %}

Is there a way to do this in twig?

I know I could put a condition in within the loop to check this status, but that's messing with the limit filter as I need to show 6 non video posts, rather than grabbing 6 posts first, and then filtering out the video posts.

jsunsawyer commented 3 years ago

I'd also like to know if there's a way to skip videos. They seem to have poor thumbnails when embedding images into a site.

kringkaste commented 3 years ago

Hi @ljclark and @jsunsawyer ! We can only scratch the latest 12 posts from the profile page. We do not get more posts in any way. If 10 of 12 posts are videos and we (or you) skip or filter them, you only have 2 posts left. Will this be ok for you?

jsunsawyer commented 3 years ago

@kringkaste Oh that's a bummer. I suppose this option would still be a bit helpful, as it'd skip downloading anything we don't want to use. (Already skipping anything that isVideo in our query.)

ljclark commented 3 years ago

Yeah this would still be helpful I think, even if it limits the amount of posts we'll actually output.

Is there a reason for the 12 post limit @kringkaste - guessing thats an Instagram rate limit or something?

fleaz commented 3 years ago

@ljclark Because IG does not have a usable API, we need to scrape the website to get the posts. And without executing JS and running a full-fledged headless browser to simulate scrolling, you only get 12 images in the first html response.