| @@ -35,9 +35,9 @@ | ||
| 35 | 35 | public function get_image_size() { |
| 36 | 36 | /** |
| 37 | 37 | * Filter: 'wpseo_twitter_image_size' - Allow changing the Twitter Card image size. |
| 38 | 38 | * |
| 39 | - * @api string $featured_img Image size string. | |
| 39 | + * @param string $featured_img Image size string. | |
| 40 | 40 | */ |
| 41 | 41 | return (string) \apply_filters( 'wpseo_twitter_image_size', 'full' ); |
| 42 | 42 | } |
| 43 | 43 | |
| @@ -43,14 +43,16 @@ | ||
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * Retrieves an image url by its id. |
| 46 | 46 | * |
| 47 | - * @codeCoverageIgnore It is a wrapper method. | |
| 48 | - * | |
| 49 | 47 | * @param int $image_id The image id. |
| 50 | 48 | * |
| 51 | - * @return string The image url. | |
| 49 | + * @return string The image url. Empty string if the attachment is not valid. | |
| 52 | 50 | */ |
| 53 | 51 | public function get_by_id( $image_id ) { |
| 52 | + if ( ! $this->image->is_valid_attachment( $image_id ) ) { | |
| 53 | + return ''; | |
| 54 | + } | |
| 55 | + | |
| 54 | 56 | return $this->image->get_attachment_image_source( $image_id, $this->get_image_size() ); |
| 55 | 57 | } |
| 56 | 58 | } |