{"id":9624,"date":"2022-11-19T15:05:19","date_gmt":"2022-11-19T15:05:19","guid":{"rendered":"https:\/\/stevepedwards.today\/DebianAdmin\/?p=9624"},"modified":"2023-10-28T20:10:24","modified_gmt":"2023-10-28T19:10:24","slug":"wordpress-images-not-showing-rare-solution","status":"publish","type":"post","link":"https:\/\/stevepedwards.today\/DebianAdmin\/wordpress-images-not-showing-rare-solution\/","title":{"rendered":"WordPress Images Not Showing &#8211; Rare Solution"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_9624\" class=\"pvc_stats all  \" data-element-id=\"9624\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>I have spent the last 3 days going mad trying to find the reason for most of my images on my home site not showing images in Posts or the Media library:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-9644 aligncenter\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/NoImage.png\" alt=\"\" width=\"1921\" height=\"1033\" \/><\/p>\n<p><a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/NoLib.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-9647 aligncenter\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2022\/11\/NoLib.png\" alt=\"\" width=\"1921\" height=\"1033\" \/><\/a><\/p>\n<p>I tried every solution I found on the web - and then some! - to no avail, until day three when someone mentioned the .htaccess file in the wp-content folder! These failed \"solutions\" included trying:<\/p>\n<p>3 different PHP versions; 7.4, 8.0 and 8.1. (see prior Posts for details(<\/p>\n<p>Different themes<\/p>\n<p>Clearing cache (if you use a caching plugin e.g. <strong>W3 Total Cache<\/strong>)<\/p>\n<p>Disabling all plugins<\/p>\n<p>Increasing memory limits via <span style=\"color: #0000ff;\">sudo vi \/etc\/php\/8.0\/apache2\/php.ini<\/span><br \/>\n<span style=\"color: #ff0000;\">memory_limit = 256M<\/span><\/p>\n<p>Increasing memory limits via \/(site dir)\/wp-config.php;<span style=\"color: #0000ff;\"> sudo vi ...\/wp-config.php <\/span><\/p>\n<p><span style=\"color: #ff0000;\">define('WP_MEMORY_LIMIT', '256M');<\/span><\/p>\n<p>Installing wp-cli (see prior Post on this) and running; <span style=\"color: #0000ff;\">wp media regenerate --yes<\/span><\/p>\n<p><a class=\"thickbox open-plugin-details-modal\" href=\"https:\/\/stevepedwards.today\/ElectronicsStuff\/wp-admin\/plugin-install.php?tab=plugin-information&amp;plugin=regenerate-thumbnails&amp;TB_iframe=true&amp;width=600&amp;height=550\">Regenerate Thumbnails<\/a> plugin<\/p>\n<p>Database repair using PHPMYADMIN<\/p>\n<p>I'm nothing if not persistent...<\/p>\n<p>It seems, I don't know how or why, but there were many duplicate Posts but with different Post IDs that have been exported and re-imported to\/from various .xml files over the past 10 years, which have a corresponding image ID in the main database, so I had uploaded a particular incorrect .xml backup from disorganised backup files, then deleted INCORRECT duplicates of those Posts, and re - exported them without checking which Post version worked properly before deleting a duplicate - or noticing they had different Post Id numbers! Stupid idea in WordPress though for having Posts that will only upload images according to an image ID and not just upload from the link address in a Post - whatever Post ID it has, in my view...<\/p>\n<p>But there was another event that seemingly solved the issue immediately, before I got into the Post ID issue that I now cannot re-create to show ( possibly because the working database is installed now over the prior image blocking version?)<\/p>\n<p>I had an .htaccess file in the W:ElectronicsStuffwp-content folder, that I assume was there from a past webP image compression plugin for improving site SEO speed etc.<\/p>\n<p>As soon as I edited this back from:<\/p>\n<p>---------------------------------------<\/p>\n<p><span style=\"color: #ff0000;\"># BEGIN WebP Express<\/span><br \/>\n<span style=\"color: #ff0000;\"># The directives (lines) between `BEGIN WebP Express` and `END WebP Express` are<\/span><br \/>\n<span style=\"color: #ff0000;\"># dynamically generated, and should only be modified via WordPress filters.<\/span><br \/>\n<span style=\"color: #ff0000;\"># Any changes to the directives between these markers will be overwritten.<\/span><br \/>\n<span style=\"color: #ff0000;\"># The rules below is a result of many parameters, including the following:<\/span><br \/>\n<span style=\"color: #ff0000;\">#<\/span><br \/>\n<span style=\"color: #ff0000;\"># WebP Express options:<\/span><br \/>\n<span style=\"color: #ff0000;\"># - Redirection to existing webp: enabled<\/span><br \/>\n<span style=\"color: #ff0000;\"># - Redirection to converter: enabled<\/span><br \/>\n<span style=\"color: #ff0000;\"># - Redirection to converter to create missing webp files upon request for the webp: enabled<\/span><br \/>\n<span style=\"color: #ff0000;\"># - Destination folder: separate<\/span><br \/>\n<span style=\"color: #ff0000;\"># - Destination extension: append<\/span><br \/>\n<span style=\"color: #ff0000;\"># - Destination structure: doc-root<\/span><br \/>\n<span style=\"color: #ff0000;\"># - Image types: jpeg, png<\/span><br \/>\n<span style=\"color: #ff0000;\">#<\/span><br \/>\n<span style=\"color: #ff0000;\"># WordPress\/Server configuration:<\/span><br \/>\n<span style=\"color: #ff0000;\"># - Document root availablity: Available and its \"realpath\" is available too. Can be used for structuring cache dir.<\/span><br \/>\n<span style=\"color: #ff0000;\">#<\/span><br \/>\n<span style=\"color: #ff0000;\"># .htaccess capability test results:<\/span><br \/>\n<span style=\"color: #ff0000;\"># - mod_header working?: no<\/span><br \/>\n<span style=\"color: #ff0000;\"># - pass variable from .htaccess to script through header working?: no<\/span><br \/>\n<span style=\"color: #ff0000;\"># - pass variable from .htaccess to script through environment variable working?: yes<\/span><br \/>\n<span style=\"color: #ff0000;\">#<\/span><br \/>\n<span style=\"color: #ff0000;\"># Role of the dir that this .htaccess is located in:<\/span><br \/>\n<span style=\"color: #ff0000;\"># - Is this .htaccess in a dir containing source images?: no<\/span><br \/>\n<span style=\"color: #ff0000;\"># - Is this .htaccess in a dir containing webp images?: yes<\/span><\/p>\n<p><span style=\"color: #ff0000;\"># Rules for handling requests for webp images<\/span><br \/>\n<span style=\"color: #ff0000;\"># ---------------------------------------------<\/span><\/p>\n<p><span style=\"color: #ff0000;\"># WebP Realizer: Redirect non-existing webp images to webp-realizer.php, which will locate corresponding jpg\/png, <\/span><br \/>\n<span style=\"color: #ff0000;\"># convert it, and deliver the freshly converted webp<\/span><br \/>\n<span style=\"color: #ff0000;\">&lt;IfModule mod_rewrite.c&gt;<\/span><br \/>\n<span style=\"color: #ff0000;\">RewriteEngine On<\/span><br \/>\n<span style=\"color: #ff0000;\">RewriteCond %{REQUEST_FILENAME} !-f<\/span><br \/>\n<span style=\"color: #ff0000;\">RewriteRule ^\/?(.+).(webp)$ \/ElectronicsStuff\/wp-content\/plugins\/webp-express\/wod\/webp-realizer.php [E=DESTINATIONREL:ElectronicsStuff\/wp-content\/webp-express\/webp-images\/$0,E=WPCONTENT:ElectronicsStuff\/wp-content,NC,L]<\/span><\/p>\n<p><span style=\"color: #ff0000;\">&lt;\/IfModule&gt;<\/span><\/p>\n<p><span style=\"color: #ff0000;\"># Set Vary:Accept header if we came here by way of our redirect, which set the ADDVARY environment variable<\/span><br \/>\n<span style=\"color: #ff0000;\"># The purpose is to make proxies and CDNs aware that the response varies with the Accept header<\/span><br \/>\n<span style=\"color: #ff0000;\">&lt;IfModule mod_headers.c&gt;<\/span><br \/>\n<span style=\"color: #ff0000;\">&lt;IfModule mod_setenvif.c&gt;<\/span><br \/>\n<span style=\"color: #ff0000;\"># Apache appends \"REDIRECT_\" in front of the environment variables defined in mod_rewrite, but LiteSpeed does not<\/span><br \/>\n<span style=\"color: #ff0000;\"># So, the next lines are for Apache, in order to set environment variables without \"REDIRECT_\"<\/span><br \/>\n<span style=\"color: #ff0000;\">SetEnvIf REDIRECT_EXISTING 1 EXISTING=1<\/span><br \/>\n<span style=\"color: #ff0000;\">SetEnvIf REDIRECT_ADDVARY 1 ADDVARY=1<\/span><\/p>\n<p><span style=\"color: #ff0000;\">Header append \"Vary\" \"Accept\" env=ADDVARY<\/span><\/p>\n<p><span style=\"color: #ff0000;\"># Set X-WebP-Express header for diagnose purposes<\/span><br \/>\n<span style=\"color: #ff0000;\">Header set \"X-WebP-Express\" \"Redirected directly to existing webp\" env=EXISTING<\/span><br \/>\n<span style=\"color: #ff0000;\">&lt;\/IfModule&gt;<\/span><br \/>\n<span style=\"color: #ff0000;\">&lt;\/IfModule&gt;<\/span><\/p>\n<p><span style=\"color: #ff0000;\"># Register webp mime type <\/span><br \/>\n<span style=\"color: #ff0000;\">&lt;IfModule mod_mime.c&gt;<\/span><br \/>\n<span style=\"color: #ff0000;\">AddType image\/webp .png<\/span><br \/>\n<span style=\"color: #ff0000;\">&lt;\/IfModule&gt;<\/span><\/p>\n<p><span style=\"color: #ff0000;\"># END WebP Express<\/span><\/p>\n<p>--------------------------------------<\/p>\n<p>to default WP:<\/p>\n<p>----------------------------------------<\/p>\n<p><span style=\"color: #ff0000;\"># BEGIN WordPress<\/span><br \/>\n<span style=\"color: #ff0000;\">RewriteEngine On<\/span><br \/>\n<span style=\"color: #ff0000;\">RewriteBase \/<\/span><br \/>\n<span style=\"color: #ff0000;\">RewriteRule ^index.php$ - [L]<\/span><br \/>\n<span style=\"color: #ff0000;\">RewriteCond %{REQUEST_FILENAME} !-f<\/span><br \/>\n<span style=\"color: #ff0000;\">RewriteCond %{REQUEST_FILENAME} !-d<\/span><br \/>\n<span style=\"color: #ff0000;\">RewriteRule . \/index.php [L]<\/span><br \/>\n<span style=\"color: #ff0000;\"># END WordPress<\/span><\/p>\n<hr \/>\n<p>When the page was refreshed with Shift-F5 (to empty page cache) - all the images appeared in the Posts and in the Media Library!<\/p>\n<p>So, it seems WP may not link the image with the incorrect Post ID (even though the image http link address is correct!!) so you will have just an empty placeholder in the Post page and empty thumbnails in the Media Library OR you may have a non standard, plugin created, image blocking .htaccess file somewhere in your content folder...<\/p>\n<p>Absolute nightmare...<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_9624\" class=\"pvc_stats all  \" data-element-id=\"9624\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>I have spent the last 3 days going mad trying to find the reason for most of my images on my home site not showing images in Posts or the Media library: I tried every solution I found on the web - and then some! - to no avail, until day three when someone mentioned <a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/wordpress-images-not-showing-rare-solution\/\" class=\"more-link\">...<span class=\"screen-reader-text\">\u00a0 WordPress Images Not Showing &#8211; Rare Solution<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-9624","post","type-post","status-publish","format-standard","hentry","category-post"],"a3_pvc":{"activated":true,"total_views":25,"today_views":0},"_links":{"self":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/9624","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/comments?post=9624"}],"version-history":[{"count":10,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/9624\/revisions"}],"predecessor-version":[{"id":9966,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/9624\/revisions\/9966"}],"wp:attachment":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/media?parent=9624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/categories?post=9624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/tags?post=9624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}