Skip to content

Instantly share code, notes, and snippets.

@grobertson
Created May 25, 2016 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grobertson/1b5aa0e4834b59b375efc6aa8fa705b9 to your computer and use it in GitHub Desktop.
Save grobertson/1b5aa0e4834b59b375efc6aa8fa705b9 to your computer and use it in GitHub Desktop.
def get_width(self, width):
"""Returns an acceptable width from a requested width.
Per https://developers.facebook.com/docs/plugins/embedded-posts/, FB
embeds must be between 350 and 750 pixels wide.
If no width passed, default to 360, else get as close to requested
width as possible while following FB's guidelines.
"""
if not width:
width = 585
elif width > 750:
width = 750
elif width < 350:
width = 350
return width
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment