Skip to content

Commit

Permalink
Step 21.37: Create DisplayMainImage pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored and DAB0mB committed Dec 14, 2016
1 parent 553687d commit 4710ef6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions client/imports/app/shared/display-main-image.pipe.ts
@@ -0,0 +1,25 @@
import {Pipe, PipeTransform} from '@angular/core';
import { Images } from '../../../../both/collections/images.collection';
import { Party } from '../../../../both/models/party.model';

@Pipe({
name: 'displayMainImage'
})
export class DisplayMainImagePipe implements PipeTransform {
transform(party: Party) {
if (!party) {
return;
}

let imageUrl: string;
let imageId: string = (party.images || [])[0];

const found = Images.findOne(imageId);

if (found) {
imageUrl = found.url;
}

return imageUrl;
}
}

0 comments on commit 4710ef6

Please sign in to comment.