Image preview directive #461
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I've been missing image preview with this library, so I made my own. Unlike #368 solution multiple images can be previewed.
It's not perfect (doesn't detect if it's not an image), but if @valorkin thinks this could be somehow included I'm up for it. Should temporarily solve #294
image-preview.directive.ts
Example usage
+1
Can any one tried how to show the video preview .I need to show the preview of a video before it is uploaded.?
thanks
+1
Thank you. It works like magic.
Thanks! I used this for image preview before upload. But does anyone have an idea how to show preview in case the user wants to upload a pdf file?
Thank you @BojanKogoj, your solution works very well!
Will this be integrated into the plugin at some point?
There is no open pull request with this. If one is provided it will be investigated and probably merged.
Hi
can we preview the pdf file ?
I made a workaround so that it check file type too, if the file is pdf it shows an iframe element, and if its any other file format (png, jpg, jpeg) it shows an img element.
Hi,
If i am using this code getting error , please find the below bold lines what we getting error
Can't bind to 'image' since it isn't a known property of 'img'.
"<img src="" imgPreview [ERROR ->][image]="item?._file" class="media-object" />
Please help on this to resolved
@Pushpanandhini you most probably forgot to import Directive.
@BojanKogoj , thank you image preview working ..
Anyone have idea to preview the Video, Doc related files uploading?
for video preview, use like this,
component:
videoPreviewPath = 'http://vjs.zencdn.net/v/oceans.mp4';I've done some modifications to detect if it is an image or a pdf file. It's pretty simple and you can easily adjust to your preferences of file type.
image-preview.directive.ts
image-preview.component.ts
Example usage
@isabelatelles Like your implementation , tried it it's working thankxxxx
Thanks to @BojanKogoj and to @isabelatelles for these awesome directives
Thanks for the implementation @BojanKogoj and the improvements @isabelatelles.
I made some modifications that makes the code more clean:
media-preview.directive.ts
Usage
Note: If you want include the preview of both (Image and PDF), you can add
*ngIfstatement as follows:*ngIf="item?._file.type === 'application/pdf'"in<object>*ngIf="item?._file.type.startsWith('image')"for<img>Thank you so much! You saved me!!!!
@JulianSalomon and @isabelatelles thanks for sharing these valuable improvements! It works like a charm.
@BojanKogoj, I was looking for this from long time, finally got it. highly appreciate. thanks a lot
it works awsome with ng2FileSelect
Muchas gracias! Thank very much! @BojanKogoj