Migration to WP - Couldn't load image

Situation:

I'm trying to migrate static page made with HTML/CSS/JS into Wordpress. The images won't load. They work in HTML, but when I migrate into PHP there are only alt-descriptions visible. Upon examining it in the Mozilla Dev Tools, there is a correct link to the image that displays the image upon clicking. However, on the migrated WP site there's an error Couldn't load image. Directory seems correct, but image just won't load.

What I tried.

  1. get_theme_file_uri()

img src=?php echo get_theme_file_uri('/img/landing/landing__cat-headphones--fb.png') ? class=d-block mx-lg-auto img-fluid landing__cat-headphones--img alt=lingcat-headphones loading=lazy

This one gets me a working link in the dev tools that I can click and it opens the image correctly. However on the page only alt-desc appears and dev tools displays Couldn't load image.

  1. get_template_directory_uri()

img src=?php echo esc_url( get_template_directory_uri() . '//img/landing/landing__cat-headphones--fb.png' ); ? class=d-block mx-lg-auto img-fluid landing__cat-headphones--img alt=lingcat-headphones loading=lazy

This one does pretty much the same thing like the method above.

  1. Uploading the image into Media library and pasting the code to the src

img src=http://localhost/wp-content/uploads/2022/05/landing__cat-headphones-fb.png class=d-block mx-lg-auto img-fluid landing__cat-headphones--img alt=lingcat-headphones loading=lazy Again, the same thing. I can access the image via dev tools, so I'd assume the dir is correct, but WP just won't display the image.

What else could I do?

Topic uploads directory images migration Wordpress

Category Web


Due to Jacob Peattie's comment I decided to exam the HTML around rather than beating around the src-bush and it turned out that the thing was the one causing problems. Once I took the image out of it, it displayed itself properly.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.