Skip to content

Image in <img>-tag not shown if livereload is enabled #2685

@kensodemann

Description

@kensodemann

From @big-r81 on August 21, 2017 15:12

Ionic version: (check one with "x")
[ ] 1.x (For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1)
[ ] 2.x
[x] 3.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

App is running on device

(livereload enabled: ionic cordova run ios --device --livereload)
Taking a picture with Cordova (destinationType = FILE_URI) and using this file path as
src in an image tag, the picture is not shown in the UI.

(livereload disabled: ionic cordova run ios --device)
Taking a picture with Cordova (destinationType = FILE_URI) and using this file path as
src in an image tag, the picture is shown in the UI.

Expected behavior:

The picture should be shown regardless of whether livereload is enabled or diesabled.

Steps to reproduce:

  1. Create new blank project
  2. Install Cordova Camera plugin + add it no app.module.ts
  3. replace home.ts and home.html with versions below!
  4. Run on device without livereload: ionic cordova run ios --device
  5. Run on device with livereload: ionic cordova run ios --device --livereload

Related code:
home.ts

import { Component } from '@angular/core';
import { Camera, CameraOptions } from "@ionic-native/camera";

@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
})
export class HomePage {

  imageUrl: string = '';

  constructor(public camera: Camera) {}

  onTakePhoto() {
    const options: CameraOptions = {
      quality: 100,
      correctOrientation: true
    };
    this.camera.getPicture(options).then((imageData) => {
      console.log("FILE: " + imageData);
        this.imageUrl = imageData;
    }, (err) => {
      console.log(err);
    });
  }
}

home.html:

<ion-header>

  <ion-navbar>
    <ion-title>home</ion-title>
  </ion-navbar>

</ion-header>


<ion-content padding>
  <ion-grid>
    <ion-row>
      <ion-col text-center>
        <h5>Take a Photo!</h5>
      </ion-col>
    </ion-row>
    <ion-row *ngIf="imageUrl != ''">
      <ion-col>
        <img [src]="imageUrl">
      </ion-col>
    </ion-row>
    <ion-row>
      <button
        ion-button
        block
        outline
        type="button"
        icon-left
        (click)="onTakePhoto()">
        <ion-icon name="camera">
          Open Camera
        </ion-icon>
      </button>
    </ion-row>
  </ion-grid>
</ion-content>

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.9.2
    ionic (Ionic CLI) : 3.9.2

global packages:

    Cordova CLI : 7.0.1 

local packages:

    @ionic/app-scripts : 2.1.3
    Cordova Platforms  : ios 4.4.0
    Ionic Framework    : ionic-angular 3.6.0

System:

    ios-deploy : 1.9.1 
    Node       : v8.1.3
    npm        : 5.3.0 
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b 

Copied from original issue: ionic-team/ionic-framework#12714

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions