Commit 15c4e83636 for wordpress.org
commit 15c4e83636b1c4a0fc83c8aab220ed30ea31a692
Author: joedolson <joedolson@git.wordpress.org>
Date: Sun Oct 4 21:41:51 2026 +0000
Media: Test for DOMDocument before checking embedded alt text.
`DOMDocument` is not a required library for WordPress, and all other uses have validation via `class_exists`. Add a check to verify the library is available before attempting to use.
Props smerriman, therssoftware, siliconforks, jorbin, joedolson.
Fixes #66221.
Built from https://develop.svn.wordpress.org/trunk@64089
git-svn-id: http://core.svn.wordpress.org/trunk@63248 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php
index c3a4a8d769..9144a4be03 100644
--- a/wp-admin/includes/image.php
+++ b/wp-admin/includes/image.php
@@ -1083,10 +1083,15 @@ function wp_read_image_metadata( $file ) {
* @since 7.0.0
*
* @param string $file File path to the image.
- * @return string Embedded alternative text.
+ * @return string Embedded alternative text, empty when there is no alt text or DOM extension is not installed.
*/
function wp_get_image_alttext( $file ) {
- $alt_text = '';
+ $alt_text = '';
+
+ if ( ! class_exists( 'DOMDocument', false ) ) {
+ return $alt_text;
+ }
+
$img_contents = file_get_contents( $file );
if ( false === $img_contents ) {
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 876dd9b9cc..7dd0c8fd7e 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-64088';
+$wp_version = '7.2-alpha-64089';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.