Skip to content

Commit

Permalink
Prevent no image being found if no image has priority 0. `"metadata.p…
Browse files Browse the repository at this point in the history
…riority": 0` filter will fail to find an image if none has priority 0, so sort is used instead. (#1392)
  • Loading branch information
priezz authored and Aaron Judd committed Sep 21, 2016
1 parent 9f00830 commit 2e03461
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ Template.productGridItems.helpers({
media: function () {
const media = Media.findOne({
"metadata.productId": this._id,
"metadata.priority": 0,
"metadata.toGrid": 1
}, { sort: { uploadedAt: 1 } });
}, {
sort: { "metadata.priority": 1, uploadedAt: 1 }
});

return media instanceof FS.File ? media : false;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ Template.productList.helpers({
if (variants.length > 0) {
const variantId = variants[0]._id;
defaultImage = Media.findOne({
"metadata.variantId": variantId,
"metadata.priority": 0
"metadata.variantId": variantId
}, {
sort: { "metadata.priority": 1, uploadedAt: 1 }
});
}
if (defaultImage) {
Expand Down

0 comments on commit 2e03461

Please sign in to comment.