Skip to content

Commit

Permalink
TASK: Remove restriction to image posts as contemporary Instagram con…
Browse files Browse the repository at this point in the history
…tent can also be albums and reels, so we will try thumbnail_url first and then media_url
  • Loading branch information
gradinarufelix committed Oct 16, 2023
1 parent 9605377 commit 0dacade
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getFeed()
$token = $this->getToken()['token'];

$apiData = [
'fields' => 'id,caption,permalink,media_type,media_url,timestamp',
'fields' => 'id,caption,permalink,media_type,media_url,thumbnail_url,timestamp',
'access_token' => $token
];

Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Fusion/Image.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ prototype(CodeQ.Instagram:Image) < prototype(Neos.Fusion:Component) {
renderer = afx`
<li>
<a href={props.item.permalink} target="_blank">
<img src={props.item.media_url} alt={props.item.caption} />
<img src={props.item.thumbnail_url || props.item.media_url} alt={props.item.caption} />
</a>
</li>
`
Expand Down
6 changes: 3 additions & 3 deletions Resources/Private/Fusion/ImagesList.fusion
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
prototype(CodeQ.Instagram:ImagesList) < prototype(Neos.Fusion:Component) {
limit = 6
# currently get images returns up to 24 items as first page
# but since not all feed items are images, you might get less and should consider getting
# a second page when you need more then ~10 images.
collection = ${Array.filter(Instagram.getFeed(), item => item.media_type == 'IMAGE')}
# but since not all feed items have a media_url or a thumbnail_url
# consider getting a second page when you need more then ~10 images.
collection = ${Array.filter(Instagram.getFeed(), item => item.thumbnail_url || item.media_url)}
attributes = Neos.Fusion:Attributes

renderer = afx`
Expand Down

0 comments on commit 0dacade

Please sign in to comment.