diff --git a/client/imports/app/shared/display-main-image.pipe.ts b/client/imports/app/shared/display-main-image.pipe.ts new file mode 100644 index 000000000..c98e95208 --- /dev/null +++ b/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; + } +} \ No newline at end of file