= \htmlentities( $img->getAttribute( 'src' ), ( \ENT_QUOTES | \ENT_SUBSTITUTE | \ENT_HTML401 ), $charset ); $classes = $img->getAttribute( $attribute ); $id = $this->extract_id_of_classes( $classes ); $images[ $src ] = $id; } return $images; } /** * Extracts image ID out of the image's classes. * * @param string $classes The classes assigned to the image. * * @return int The ID that's extracted from the classes. */ protected function extract_id_of_classes( $classes ) { if ( ! $classes ) { return 0; } /** * Filter 'wpseo_extract_id_pattern' - Allows filtering the regex patern to be used to extract image IDs from class/attribute names. * * Defaults to the pattern that extracts image IDs from core's `wp-image-` native format in image classes. * * @api string The regex pattern to be used to extract image IDs from class names. Empty string if the whole class/attribute should be returned. */ $pattern = \apply_filters( 'wpseo_extract_id_pattern', '/(?