SubredditStylesheet

class praw.models.reddit.subreddit.SubredditStylesheet(subreddit)

Provides a set of stylesheet functions to a Subreddit.

__call__()

Return the subreddit’s stylesheet.

To be used as:

stylesheet = reddit.subreddit('SUBREDDIT').stylesheet()
__init__(subreddit)

Create a SubredditStylesheet instance.

Parameters:subreddit – The subreddit associated with the stylesheet.

An instance of this class is provided as:

reddit.subreddit('SUBREDDIT').stylesheet
delete_banner()

Remove the current subreddit (redesign) banner image.

Succeeds even if there is no banner image.

Example:

reddit.subreddit('SUBREDDIT').stylesheet.delete_banner()
delete_banner_additional_image()

Remove the current subreddit (redesign) banner additional image.

Succeeds even if there is no additional image. Will also delete any configured hover image.

Example:

reddit.subreddit('SUBREDDIT').stylesheet.delete_banner_additional_image()
delete_banner_hover_image()

Remove the current subreddit (redesign) banner hover image.

Succeeds even if there is no hover image.

Example:

reddit.subreddit('SUBREDDIT').stylesheet.delete_banner_hover_image()
delete_header()

Remove the current subreddit header image.

Succeeds even if there is no header image.

Example:

reddit.subreddit('SUBREDDIT').stylesheet.delete_header()
delete_image(name)

Remove the named image from the subreddit.

Succeeds even if the named image does not exist.

Example:

reddit.subreddit('SUBREDDIT').stylesheet.delete_image('smile')
delete_mobile_header()

Remove the current subreddit mobile header.

Succeeds even if there is no mobile header.

Example:

reddit.subreddit('SUBREDDIT').stylesheet.delete_mobile_header()
delete_mobile_icon()

Remove the current subreddit mobile icon.

Succeeds even if there is no mobile icon.

Example:

reddit.subreddit('SUBREDDIT').stylesheet.delete_mobile_icon()
update(stylesheet, reason=None)

Update the subreddit’s stylesheet.

Parameters:stylesheet – The CSS for the new stylesheet.

Example:

reddit.subreddit('SUBREDDIT').stylesheet.update(
    'p { color: green; }', 'color text green')
upload(name, image_path)

Upload an image to the Subreddit.

Parameters:
  • name – The name to use for the image. If an image already exists with the same name, it will be replaced.
  • image_path – A path to a jpeg or png image.
Returns:

A dictionary containing a link to the uploaded image under the key img_src.

Raises prawcore.TooLarge if the overall request body is too large.

Raises APIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

Example:

reddit.subreddit('SUBREDDIT').stylesheet.upload('smile', 'img.png')
upload_banner(image_path)

Upload an image for the subreddit’s (redesign) banner image.

Parameters:image_path – A path to a jpeg or png image.

Raises prawcore.TooLarge if the overall request body is too large.

Raises APIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

Example:

reddit.subreddit('SUBREDDIT').stylesheet.upload_banner('banner.png')
upload_banner_additional_image(image_path, align=None)

Upload an image for the subreddit’s (redesign) additional image.

Parameters:
  • image_path – A path to a jpeg or png image.
  • align – Either left, centered, or right. (default: left).

Raises prawcore.TooLarge if the overall request body is too large.

Raises APIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

Example:

reddit.subreddit('SUBREDDIT').stylesheet.upload_banner_additional_image('banner.png')
upload_banner_hover_image(image_path)

Upload an image for the subreddit’s (redesign) additional image.

Parameters:image_path – A path to a jpeg or png image.

Fails if the Subreddit does not have an additional image defined

Raises prawcore.TooLarge if the overall request body is too large.

Raises APIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

Example:

reddit.subreddit('SUBREDDIT').stylesheet.upload_banner_hover_image('banner.png')
upload_header(image_path)

Upload an image to be used as the Subreddit’s header image.

Parameters:image_path – A path to a jpeg or png image.
Returns:A dictionary containing a link to the uploaded image under the key img_src.

Raises prawcore.TooLarge if the overall request body is too large.

Raises APIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

Example:

reddit.subreddit('SUBREDDIT').stylesheet.upload_header('header.png')
upload_mobile_header(image_path)

Upload an image to be used as the Subreddit’s mobile header.

Parameters:image_path – A path to a jpeg or png image.
Returns:A dictionary containing a link to the uploaded image under the key img_src.

Raises prawcore.TooLarge if the overall request body is too large.

Raises APIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

For example:

reddit.subreddit('SUBREDDIT').stylesheet.upload_mobile_header(
    'header.png')
upload_mobile_icon(image_path)

Upload an image to be used as the Subreddit’s mobile icon.

Parameters:image_path – A path to a jpeg or png image.
Returns:A dictionary containing a link to the uploaded image under the key img_src.

Raises prawcore.TooLarge if the overall request body is too large.

Raises APIException if there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.

For example:

reddit.subreddit('SUBREDDIT').stylesheet.upload_mobile_icon(
    'icon.png')