Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to add a preview picture to a child theme in Appearances -> Themes?


  • stephunique
    Participant

    @stephunique

    For context, I am not a developer.

    I created a child theme manually for BuddyX and the child theme works. However, the child theme does not have one of those preview picture that shows what the theme looks like in the Appearances -> Themes page and I wanted to add one.

    Version details: BuddyX Version: 4.7.5 with Buddypress Version 14.2.1 and WordPress Version 6.7.1.

    I know that in the buddyx folder in the hosting back end (wp-content -> themes -> buddyx), there is an image file called “screenshot.png”. This is a PNG file and it is what the original theme preview picture is. So I assumed that if I add an image file to my buddyx-child folder, it will also be the preview picture.

    To test this, first I copied that original “screenshot.png” to the child theme folder and purged the cache in my wordpress dashboard and sure enough, it became the preview picture of the child theme.

    Now that I know it works, I downloaded this file, deleted it from the child theme folder, and edited it by opening it in a image editor and adding the word “CHILD” in large letters across the picture, saved it first as “screenshot.jpg” then also “screenshot.png”, with the intention of using that so I can tell the child theme and the parent theme apart visually. When I uploaded either of them (the new jpg and the png, one at a time and deleting the one I don’t need from the folder) the picture nonetheless showed the orignal “screenshot.png” without the word “CHILD” on it.

    As an experiment, I then uploaded a random jpg and renamed it in my hosting back end, to “screenshot.jpg” without changing the extension. When I purged the cache in my wordpress dashboard, the preview picture for the child theme showed this new jpg instead of the old original “screenshot.png”. (Nothing shows if you don’t rename the file to “screenshot”, it must be “screenshot”). So it seems the image can be jpg or png as long as it is called “screenshot”.

    So then I deleted this random jpg, and I tried to upload the new “screenshot.png” with the word “CHILD” on it again, but the same thing happened. This is really strange since I deleted the original “screenshot.png” and cleared my cache but it still seems to remember what it was before.

    What is even stranger is that when I upload ANY jpg file then rename it to “screenshot” and keep the extension as “jpg”, the picture that shows as the preview picture in my wordpress dashboard is the random jpg I uploaded earlier. This happens no matter what jpg file I upload.

    Stranger still: If I upload a jpg file and change the name to “screenshot” as well as change the extension to “.png”, then the image that shows as the preview picture is the original “screenshot.png” from the parent theme. Same if I upload any PNG file.

    Anyone have any ideas?

Viewing 1 replies (of 1 total)

  • emaralive
    Participant

    @emaralive

    Hi @stephunique,

    Long story short, the “screenshot” file is added to the wp cache, e.g., $this->cache_add( 'screenshot', 'screenshot.' . $ext );.

    Additionally, it appears that the extensions for the “screenshot” file can be any of the following 'png', 'gif', 'jpg', 'jpeg', 'webp', 'avif'.

    Last but not least, in the future, it would, most likely, be best to ask WordPress related questions in one the WordPress related forums.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar