Image
Image Class
Represents an image object from the ESPN API, typically associated with players, teams, or events.
Attributes:
Name | Type | Description |
---|---|---|
image_json |
dict
|
The raw JSON data representing the image. |
espn_instance |
object
|
The ESPN API instance used for context or further data retrieval. |
ref |
str
|
The direct URL to the image. |
name |
str
|
A human-readable name derived from the image's |
width |
int
|
The width of the image in pixels. |
height |
int
|
The height of the image in pixels. |
alt |
str
|
Alternative text for the image. |
rel |
list
|
A list of roles describing the image (e.g., "default", "profile"). |
last_updated |
str
|
The last updated timestamp of the image. |
Methods:
Name | Description |
---|---|
__init__ |
Initializes the Image object using JSON data and a reference to the ESPN API wrapper. |
__repr__ |
Returns a string representation of the Image object. |
_load_image_data |
Parses and loads image metadata from the provided JSON data. |
load_image |
Downloads and returns the binary content of the image from the reference URL. |
Source code in pyespn/classes/image.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
espn_instance
property
PYESPN: the espn client instance associated with the class
name
property
str: name of the image
ref
property
str: url for the image
__init__(image_json, espn_instance)
Initializes an Image instance using the provided image JSON data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_json
|
dict
|
A dictionary containing image metadata from the ESPN API. |
required |
espn_instance
|
object
|
A reference to the PyESPN instance. |
required |
Source code in pyespn/classes/image.py
__repr__()
Returns a string representation of the Image instance.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A string showing the image's name. |
load_image()
Downloads and returns the image content from the object's reference URL.
Returns:
Name | Type | Description |
---|---|---|
bytes |
bytes
|
The binary content of the image. |
Source code in pyespn/classes/image.py
to_dict()
Converts the Image instance to its original JSON dictionary.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The images's raw JSON data. |