Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added correct image for FB sharing (master) #33784

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lms/templates/courseware/course_about.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@

<%inherit file="../main.html" />
<%block name="headextra">
## OG (Open Graph) title and description added below to give social media info to display
<%
site_domain = static.get_value('site_domain', settings.SITE_NAME)
site_protocol = 'https' if settings.HTTPS == 'on' else 'http'

og_img_url = "{protocol}://{domain}{path}".format(
protocol=site_protocol,
domain=site_domain,
path=course_image_urls['large']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this handle the case where the course doesn't have an image set?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pdpinch
If the course doesn't have the image set - then it falls back to the default (copied from common.py lms's settings):

DEFAULT_COURSE_ABOUT_IMAGE_URL = 'images/pencils.jpg'

You can check the def image_urls(self) property from the CourseOverview model for details on how the course_image_urls dict is populated.

In other words - the handling is the same as for the course image on the course about page.

)
%>
## OG (Open Graph) title, image and description added below to give social media info to display
## (https://developers.facebook.com/docs/opengraph/howtos/maximizing-distribution-media-content#tags)
<meta property="og:title" content="${course.display_name_with_default}" />
<meta property="og:image" content="${og_img_url}" />
<meta property="og:description" content="${get_course_about_section(request, course, 'short_description')}" />
</%block>

Expand Down
Loading