Plugin not picking up screenshot for custom template
-
Hi there,
First of all – great plugin! Currently developing a book review site for someone and this is ideal. Thank you.
Anyway, we’ve made a custom template for our client (based on your own Inverse template), just adding some extra taxonomy bits and pieces and making a few tweaks. It’s all working well, but in the Admin panel (Reviews->Settings->Templates) the screenshot for our new template isn’t showing properly (it just shows a broken image link). The template is there and it all works fine, it’s just the image link for our template’s screenshot.png in the admin page that is broken.
I’ve taken a look at the URI that the admin panel is trying to use for the image and I think I can see what might be happening. We pretty much always create and install a child theme on any website we build, but the admin panel is trying to find the image under the parent theme stylesheet/template directory.
I haven’t checked yet, but I’m guessing that the code to load the image in the admin page is using something like get_template_directory_uri() to build the path to the screenshot.png file. This will work fine for a single root or parent theme, but if a child theme is being used, it returns a URI for the parent. The admin code would need to use get_stylesheet_directory_uri() to get the right path when a child theme is being used.
Alternatively, since WordPress 4.7, there’s a get_theme_file_uri() call that could be used instead. It could be called with a string parameter something like:
‘/rcno_templates/’ . $layout . ‘/screeshot.png’
to get the URI to the correct screenshot image. The get_theme_file_uri() function works correctly with both parent/root and child themes.
Thanks again for the great plugin and hope the above is helpful. It’s not a high priority thing to fix in the grand scheme of things (it’s just cosmetic in the admin page) but it’s probably something that you would want to look at.
Adrian
- The topic ‘Plugin not picking up screenshot for custom template’ is closed to new replies.