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_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_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')