Skip to content

Commit c38194a

Browse files
committed
Update functions reference in the readme.md file
1 parent dcb6262 commit c38194a

File tree

1 file changed

+35
-61
lines changed

1 file changed

+35
-61
lines changed

readme.md

Lines changed: 35 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -38,97 +38,71 @@ add_action( 'after_setup_theme', 'custom_theme_setup' );
3838

3939

4040
---
41+
### Function Reference
4142

42-
#### tevkori_get_sizes( $id, $size, $args )
43+
#### wp_get_attachment_image_sizes( $size, $image_meta = null, $attachment_id = 0, $image_src = null )
4344

44-
Returns a valid source size value for use in a 'sizes' attribute. The parameters include the ID of the image, the default size of the image, and an array or string containing of size information. The ID parameter is required. [Link](https://github.com/ResponsiveImagesCG/wp-tevko-responsive-images/blob/master/wp-tevko-responsive-images.php#L28)
45+
Create 'sizes' attribute value for an image.
4546

46-
***Usage Example***
47+
**Return:** (string|bool) A valid source size value for use in a 'sizes' attribute or false.
4748

48-
```
49-
<img src="myimg.png" sizes="<?php echo tevkori_get_sizes( 11, 'medium' ); ?>" >
50-
```
5149

52-
By default, the sizes attribute will be declared as 100% of the viewport width when the viewport width is smaller than the width of the image, or to the width of the image itself when the viewport is larger than the image. In other words, this:
53-
54-
`(max-width: {{image-width}}) 100vw, {{image-width}}`
50+
##### Parameters
5551

56-
You can override those defaults by passing your own size values as set of arrays to the `$args` parameter.
52+
**$size** (array|string)
53+
Image size. Accepts any valid image size name ('thumbnail', 'medium', etc.), or an array of width and height values in pixels (in that order).
5754

58-
*Example:*
55+
**$image_meta** (array) (Optional) The image meta data as returned by 'wp_get_attachment_metadata()'.
5956

60-
```
61-
$args = array(
62-
'sizes' => array(
63-
array(
64-
'size_value' => '10em',
65-
'mq_value' => '60em',
66-
'mq_name' => 'min-width'
67-
),
68-
array(
69-
'size_value' => '20em',
70-
'mq_value' => '30em',
71-
'mq_name' => 'min-width'
72-
),
73-
array(
74-
'size_value' => 'calc(100vm - 30px)'
75-
),
76-
)
77-
);
78-
79-
$sizes = tevkori_get_sizes( $id, 'medium', $args );
80-
```
57+
**$attachment_id** (int)
58+
(Optional) Image attachment ID. Either `$image_meta` or `$attachment_id` is needed when using the image size name as argument for `$size`.
8159

82-
Which would output a sizes value of:
83-
`(min-width: 60em) 10em, (min-width: 30em) 20em, calc(100vm - 30px)`
60+
**$image_src** (string)
61+
(Optional) The URL to the image file.
8462

85-
---
63+
##### Usage Example
8664

87-
#### tevkori_get_sizes_string( $id, $size, $args)
65+
```
66+
<img src="myimg.png" sizes="<?php echo esc_attr( wp_get_attachment_image_sizes( 'medium' ) ); ?>" >
67+
```
8868

89-
Returns A full 'sizes' attribute. The parameters include the ID of the image, the default size of the image, and an array or string containing of size information. The ID parameter is required.
69+
By default, the sizes attribute will be declared as 100% of the viewport width when the viewport width is smaller than the width of the image, or to the width of the image itself when the viewport is larger than the image. In other words, this:
9070

91-
***Usage Example***
71+
`(max-width: {{image-width}}) 100vw, {{image-width}}`
9272

93-
```
94-
<img src="myimg.png" <?php echo tevkori_get_sizes_string( 11, 'medium' ); ?> >
95-
```
73+
You can override those defaults by adding a filter to `wp_get_attachment_image_sizes`.
9674

9775
---
98-
#### tevkori_get_srcset_array( $id, $size )
9976

100-
Returns an array of image source candidates for use in a 'srcset' attribute. The parameters include the ID of the image, the default size of the image, and An array of of srcset values. The ID parameter is required. [Link](https://github.com/ResponsiveImagesCG/wp-tevko-responsive-images/blob/master/wp-tevko-responsive-images.php#L132)
77+
#### wp_get_attachment_image_srcset( $attachment_id, $size = 'medium', $image_meta = null )
10178

102-
***Usage Example***
79+
Retrieves the value for an image attachment's 'srcset' attribute.
10380

104-
```
105-
$sources = tevkori_get_srcset_array( 11, 'medium' );
81+
**Return:** (string|bool) A 'srcset' value string or false.
10682

107-
// Optionally remove a specific source from the srcset list.
108-
foreach( $sources as $key => $source ) {
109-
if ( strpos( $source, '300w' ) ) {
110-
unset( $s[$key] );
111-
}
112-
}
83+
##### Parameters
11384

114-
<img src="myimg.png" srcset="<?php implode( ', ', $sources ); ?>" >
115-
```
85+
**$attachment_id** (int)
86+
Image attachment ID.
11687

117-
---
88+
**$size** (array|string)
89+
Image size. Accepts any valid image size, or an array of width and height values in pixels (in that order). Default 'medium'.
11890

119-
#### tevkori_get_srcset_string( $id, $size )
91+
**$image_meta** (array)
92+
(Optional) The image meta data as returned by 'wp_get_attachment_metadata()'.
12093

121-
Returns A full 'srcset' attribute. The parameters include the ID of the image and its default size. The ID parameter is required. [Link](https://github.com/ResponsiveImagesCG/wp-tevko-responsive-images/blob/master/wp-tevko-responsive-images.php#L196)
12294

123-
***Usage Example***
95+
##### Usage Example
12496

12597
```
126-
<img src="myimg.png" <?php echo tevkori_get_srcset_string( 11, 'medium' ); ?> >
98+
<img src="myimg.png" srcset="<?php echo esc_attr( wp_get_attachment_image_srcset( 11, 'medium' ) ); ?>" sizes="{{custom sizes attribute}}" >
12799
```
128100

129-
**Dependencies**
101+
---
102+
103+
### Dependencies
130104

131-
The only external dependency included in this plugin is [Picturefill](http://scottjehl.github.io/picturefill/) - v2.3.0. If you would like to remove Picturefill (see notes about [browser support](http://scottjehl.github.io/picturefill/#support)), add the following to your functions.php file:
105+
The only external dependency included in this plugin is [Picturefill](http://scottjehl.github.io/picturefill/) - v3.0.1. If you would like to remove Picturefill (see notes about [browser support](http://scottjehl.github.io/picturefill/#support)), add the following to your functions.php file:
132106

133107
function mytheme_dequeue_scripts() {
134108
wp_dequeue_script('picturefill');

0 commit comments

Comments
 (0)