• Resolved DarrenMooney

    (@darrenmooney)


    Hey,

    I normally don’t post support requests as most problems can be solved with a little help from the Google machine, however nothing I’ve found has been able to help with this problem.

    As the title suggests, images are not displaying in posts.

    I’ve already confirmed that its not the image location problem I’ve seen in other topics (wp-content/uploads).

    If I try to inspect the code via Chrome’s code inspection or Firebug, the image code doesn’t show, however if I view source, the image code is there. When I try to view the image link in the source code it displays.

    The style I’m using is one I’m in the middle of creating. I’m using post formats, for this particular post its gallery.

    I’ve created a sample post for testing the images: https://tietheknotcreative.co.uk/2011/08/sample-9453/

    The image url is:
    https://tietheknotcreative.co.uk/wp-content/uploads/photo1.png

    On the page, the image should be display between the two text items; above image & below image.

    To note; I cleared and disabled cache plugins, and just to be sure, I disabled every other plugins in the off chance any where causing the problem – no joy.

    Does anyone have any suggestions?

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Darren,

    This one’s a puzzler. You might try disabling the modernizer script. Or any scripts that load external fonts.

    Interestingly, the image actually loads, THEN disappears, which makes me think it might be getting filtered on load. Maybe double check your filter settings.

    Thread Starter DarrenMooney

    (@darrenmooney)

    Thanks for the reply, Drew.

    I had considered Modernizer as a possible cause, removed it, html boilerplate and @font-face with no results.

    What exactly do you mean by filter setting?

    Well, by default, WordPress has filtered HTML settings based on capabilities. I’m assuming you’re posting using your admin account though, so you should theoretically have capabilities to post completely unfiltered HTML. Not to mention, the code is loading in the source but not on the page.

    The fact that the image loads then disappears still puzzles me. It makes me think there’s another running script loading on page load that’s causing your problem.

    Edit: Now I see your image is loading on your sample page. Did you get it figured out? Please do share if you did.

    Thread Starter DarrenMooney

    (@darrenmooney)

    Ah, I figured it out. A code I was using to detect category for conditional sidebar items:

    In functions.php:

    //
    // If is category or subcategory of $cat_id
    //
    
    if (!function_exists('is_category_or_sub')) {
    	function is_category_or_sub($cat_id = 0) {
    	    foreach (get_the_category() as $cat) {
    	    	if ($cat_id == $cat->cat_ID || cat_is_ancestor_of($cat_id, $cat)) return true;
    	    }
    	    return false;
    	}
    }

    For some reason its not allowing the image to be displayed. When its removed the image displays. I guess I’ll have to do the conditional tag another way.

    As to your conditional, I actually stumbled on something just last week that might help you out.

    I used this to check if I was in X category or a descendant:

    if (is_category('id or name') || in_category('id or name') || post_is_in_descendant_category(get_term_by('slug', 'theslug', 'category'))) {
    
    Some code here
    
    }

    You need to drop this snippet in functions.php

    Hope that helps. Don’t forget to mark your question resolved.

    Thread Starter DarrenMooney

    (@darrenmooney)

    Ah, ignore my last. That particular code wasn’t the cause, removing it while NOT removing its custom condition broke the code in my sidebar, this break caused the footer scripts to not load, which fixed the problem.

    I have found the cause – I had the following script running:

    $('article p')
        .filter(function() {
            return $.trim($(this).text()) === ''
        })
        .remove()

    To be honest, I can’t even remember why I was using this. I think I was trying something early on in the process and forgot to remove it.

    I’m sorry to have wasted your time with this stupid problem , I really shouldn’t code at 4/5am.

    Thanks again for your help and time… and thanks for that snippet.

    No time wasted, really. Just another fun problem to solve in a sea of many. Glad you got it resolved.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Images not displaying in posts’ is closed to new replies.