admin管理员组文章数量:1198385
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.
- 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".
- 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.
- 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?
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.
- 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".
- 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.
- 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?
Share Improve this question asked May 24, 2022 at 15:23 ScorpVisualScorpVisual 112 bronze badges 4 |1 Answer
Reset to default 0Due 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.
本文标签: uploadsMigration to WPCouldn39t load image
版权声明:本文标题:uploads - Migration to WP - Couldn't load image 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738572764a2100697.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
<picture>
element then the browser is going to choose an image<source>
based on its type and media query. You haven't given a media query so it's probably just choosing the first that's supported, which could be either, and I notice those are using relative URLs that are not pointing to the theme directory. – Jacob Peattie Commented May 24, 2022 at 15:58