question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a full_url property to image rendition objects

See original GitHub issue

Is your proposal related to a problem?

To include a Twitter ‘share’ image on a template, you’d typically do something like:

{% image page.social_image fill-1200x1200 as social_img %}
<meta name="twitter:image" content="{{ social_img.url }}">

However, this may return either a local URL (/media/images/foo.jpg) or an absolute URL (https://media.example.com/images/foo.jpg) depending on how media files are configured at the Django level. There’s no good way to consistently return a full absolute URL, as required for the ‘share’ image to work.

Describe the solution you’d like

Add a full_url property to the image Rendition model, which prepends settings.BASE_URL to the rendition’s url property if it begins with a /, and returns the url unchanged if not. This will then allow us to write

<meta name="twitter:image" content="{{ social_img.full_url }}">

(Using settings.BASE_URL isn’t perfect - it’s only an informal convention for Wagtail sites to define it, and it doesn’t account for multi-site installations - but it’s probably good enough for most purposes.)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
nickleecommented, Feb 12, 2021
1reaction
shreyashsrivastavacommented, May 10, 2021

Hey @sankalpmukim, are you still working in this issue? If not, I might want to work in this 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use images in templates
Full width: Creates an image rendition using width-800 , giving the <img> tag the CSS class full-width .
Read more >
SharePoint Design Manager image renditions
Describes how to create an image rendition, how to add the rendition to a page, and how to crop the rendition.
Read more >
Wagtail: How to get image rendition url and pass it along ...
I think what you can do is create a property which get's stored as an attribute. @property def rendition_url(self): url = self.header.
Read more >
Troubleshooting Archives - wiliammbr's blog
Complementing, Microsoft documentation says: “Image renditions enable you to render a single image in multiple ways. An image can be displayed ...
Read more >
Wagtail Documentation
to Django's url tag but takes a Wagtail Page object as an argument. ... While it's possible to simply insert images into.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found