Support » Theme: Tracks » Author Box Profile Images only showing for administrator

Viewing 7 replies - 1 through 7 (of 7 total)
  • Theme Author Ben Sibley


    That is odd, I can’t seem to recreate the issue. Do you have an edited version of content.php in your child theme? Can you verify that the ct_tracks_profile_image_output() function is being called?

    I have never edited that function. I have not been using a child theme (I know I should) I’ll get around to setting that up soon. I have modified other core theme functions but very minor tweaks.

    I would assume the function is being called because my profile picture shows up. But when you inspect the code for the post with no image showing up It just doesn’t write the image tag for users with a permission below Administrator?

    The code for ct_tracks_profile_image_output() is this:

    function ct_tracks_profile_image_output(){
        // use User's profile image, else default to their Gravatar
            // get the id based on the image's URL
            $image_id = ct_tracks_get_image_id(get_the_author_meta('user_profile_image'));
            // retrieve the thumbnail size of profile image
            $image_thumb = wp_get_attachment_image($image_id, 'thumbnail');
            // display the image
            echo $image_thumb;
        } else {
            echo get_avatar( get_the_author_meta( 'ID' ), 72 );

    Ok so with a little debugging I figured out what is happening. I use cloudfront and aws s3 to store my media. When you upload photos to the site they are automatically pushed to an s3 bucket. My user profile was created before I set this up and that image for whatever reason has not been migrated to the s3 bucket.

    $image_thumb = wp_get_attachment_image($image_id, 'thumbnail');
    is what is not working. I’m pretty sure due to the images being hosted externally wp_get_attachement_image will not work.

    Any thoughts on how to modify this it still pulls in the url of the image I added `
    $image_thumb = wp_get_attachment_image($image_id, ‘thumbnail’);
    ..` to see if there was actually a photo attached to the user profile and it indeed returns the full url path to the image. Which is why the default gravitar image was not being display.

    I think there is an error in how ct_tracks_get_image_id(); works because there is nothing displayed when I do print_r($image_id); for the affected posts.

    this is what image paths look like using the s3 bucket

    They are still linked in the wordpress media galley and can be attached to a post see

    I think this is why ct_tracks_get_image() isnt working is because the s3 bucket url doesn’t match the host url of the site

    Any idea’s on how I can hack this to work with the subdomain

    Theme Author Ben Sibley


    Okay I see, thanks for all the detail.

    You can remove the last conditional on line 11 of the ct_tracks_get_image() function. That’s the part that restricts the images to the same domain.

    Otherwise, you could add an “author-photos” folder to your server that doesn’t get delivered via aws and then use those URLs for the author’s photos. That would just take a couple minutes, provided there are just a handful of authors.

    hmm I tried commenting out

    if ( ! isset( $parsed_url[1] ) || empty( $parsed_url[1] ) || ( $this_host != $file_host ) ) {

    and replacing it with

    if ( ! isset( $parsed_url[1] ) || empty( $parsed_url[1] ) ) {

    But no such luck I have ran a query on my db
    SELECT ID FROM wp1_posts WHERE guid RLIKE ‘%s;”,/uploads/2015/04/28032252/IMG_7584.jpg’;

    and it produces no result very odd that it’s in the database

    Checked in my database and the path points to the s3 bucket but the guid is still set to the server path. Very odd the path on the bucket does not reflect the same path in the uploads I think that may have something to do with /uploads/2015/04/28032252/IMG_7584.jpg
    vs what was in the guid /uploads/2015/04/IMG_7584.jpg

    Might be ewww image optimization plugin that made a revision of the image before the media was moved to the s3 bucket. Still doesn’t explain why the File URL in the media library points to the s3 bucket but the guid in the DB pointed to the server.

    I updated the db manually and it’s showing now

    Theme Author Ben Sibley


    Okay that makes sense. The GUID isn’t supposed to be used as the URL, it’s just a way to provide an unique identifier for the image. Since the image’s URL doesn’t match b/c of the additional subdirectory added, the image isn’t found in the database and the function returns null rather than the image’s ID.

    I believe this is more of a limitation of the existing function than anything else.

    Another solution would be to modify the url before the sql query. You could check for a set of numbers after the month and before the image number, and remove that part of the address. That would allow all of the images to match the existing GUIDs.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Author Box Profile Images only showing for administrator’ is closed to new replies.