sensei
sensei copied to clipboard
Course settings about “Course image” not having any effect.
Reported by Gonzalo here: p1654590027797169-slack-C03BXN7UQ5V
Reproduce:
- Go to a course and add a featured image.
- Go to settings > Course > Course image and disable the option.
- Go to the course and you will still see the featured image.
Extra info:
- Looks like the Course Image option is only useful when using the legacy template system. Not having any effect when creating a course with block editor.
- Gonzalo wants to be able to set an image but not show it. Main reason is to have this featured image shown when sharing the link to a course in whatsapp or any other place where medialinks are used.
- Currently the only solution for him is to remove the featured image, which is not exactly what he wants.
- There are some plugins that could help with that: https://wordpress.org/plugins/zi-hide-featured-image/ https://wordpress.org/plugins/hide-featured-image/ but the "Course Image" setting is confusing.
I've been looking into this and there are currently a few issues I found with featured image options:
| Block Themes | Course | Lesson |
|---|---|---|
| Single Page Show | ✅ (but not custom size) | ✅ (but double image) |
| Archive Show* | ❌ | ❌ |
| Single Page Hide | ✅ | ✅ |
| Archive Hide** | ❌ | ❌ |
| PHP Template Themes | Course | Lesson |
|---|---|---|
| Single Page Show | ✅ (but not custom size) | ✅ (but double image) |
| Archive Show* | ❌ | ❌ |
| Single Page Hide | ❌ | ❌ |
| Archive Hide** | ❌ | ❌ |
*The Archive featured image display option was moved to the block metabox, so the Settings option doesn't work.
** Currently there is no option to show/hide Lesson images on the Course Page.
Example double featured image (blockbase theme):

The problem is that Sensei is trying to output inside a template using a hook, but Sensei sometimes uses PHP templates and other times uses Blocks. In the Lesson example, the reason there's a double output is that one is the theme outputting it in the header and the second one is Sensei outputting it in the sensei_single_lesson_content_inside_before hook.
Are we trying to support both php template use and block use?
My proposal:
- We get rid of outputting images in PHP templates and just rely on themes to output images appropriately https://github.com/Automattic/sensei/blob/4851abbd48ffd5bacd1139682d24764d18bb1fa1/includes/class-sensei-lesson.php#L3682
- We add some hooks so that the actual
featured_imageeither shows/hides depending on the site settings. We would hook intopost_thumbnail_htmlandpost_thumbnail_sizeto show/hide and change the image sizes.
@aaronfc what do you think?