A
A
Anatoly2015-08-21 18:40:02
React
Anatoly, 2015-08-21 18:40:02

How to display image in Yii view?

Images used to load normally on the local machine, but now they are not displayed on the hosting.
It throws out such a miracle: 104cedd3b41d42f191f1e29e645b40d3.png
I try to display it with a regular container:

<div>
 <img src="/frontend/web/img/bootles.jpg">
 </div>

Maybe it's the urlManager?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
K
karambafe, 2019-02-25
@karambafe

Are you sure that here the state is correctly updated?

this.setState({
  [e.target.id]: { inputValue: e.target.value },
});

Try using prevState and spread to explicitly overwrite:
updateInputValue({ target: { id, value } }) {
  this.setState(prevState => ({ 
     [id]: {
        ...prevState.id,
        inputValue: value,
     },
  }));
}

N
nluparev, 2019-02-25
@nluparev

PHPjedi error where setting and fetching from the state occurs.

this.setState({
            [e.target.name]: e.target.value
        });

and a selection from the state
value={this.state.name}

V
Vladimir Kalachev, 2019-02-25
@Sensetive

<input type="text"
                                       className="floating-label-input"
                                       id="name"
                                       value={this.state.name.inputValue || ''}
                                       onFocus={this.activateField}
                                       onBlur={this.disableFocus}
                                       onChange={this.updateInputValue}

Due to the fact that the initial value of inputValue is undefined, and then it changes to some kind of data entry, such an error occurs. If there is no value attribute, React treats the input as uncontrolled.

N
Nikita, 2015-08-21
@bitver

Url::to(['/img/bootles.jpg'])
Open the documentation, there is a whole page on this subject.

A
Anatoly, 2015-08-21
@Benjamin_Button

And there is. The fact is that it only works if you set the path:

<div>
        <img src="http://xxx.ru/img/bootles.jpg">
    </div>

But how to display images using internal paths?

S
Sonnabend, 2015-08-27
@sonnabend

Try:
<img src="./img/bootles.jpg">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question