Guest User

Untitled

a guest
Nov 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. readLink(url: string) {
  2. this.isBusy = true;
  3. this._http.get(`${this._helper.baseURL}/api/post/readlink?url=${encodeURIComponent(url)}`)
  4. .subscribe(
  5. data => {
  6. this.processResponse(data, url);
  7. },
  8. (err: HttpErrorResponse) => {
  9. }
  10. );
  11. }
  12.  
  13. processResponse(result, url) {
  14. if (result.images != null && result.images.length > 0) {
  15. result.images.forEach(el => {
  16. this.getMeta(el, function (res) {
  17. this.images.push(res);
  18. this.currentImage = this.images[0];
  19. });
  20. });
  21. }
  22. alert( this.images.length); // this always give zero and this was executed before my call bakc
  23. }
  24.  
  25. getMeta(url, callback) {
  26. const img = new Image();
  27. img.src = url;
  28. img.onload = function () {
  29. if (img.width > 260 && img.height > 150) {
  30. callback(url);
  31. }
  32. };
Add Comment
Please, Sign In to add comment