page-sitemap.xml fatal error with ‘Images in Sitemaps’ option is enabled

#772104
  • Resolved Saint Rollox Digital
    Rank Math free

    Hello. When I have the ‘Images in Sitemaps’ option enabled, the /page-sitemap.xml page fails with the error “/page-sitemap.xml”.

    I have enabled debugging and and it reports the following error_log. It appears to point to a problem with an image, however I’m uncertain what the problem could be. There’s nothing particularly unusual about the Media Library and all files have standard names with no special characters aside from dashes. When I disable the ‘Images in Sitemaps’ option, the /page-sitemap.xml page works again.

    [24-Mar-2024 03:14:58 UTC] PHP Fatal error: Uncaught TypeError: Unsupported operand types: string * float in /opt/bitnami/wordpress/wp-includes/media.php:467
    Stack trace:
    #0 /opt/bitnami/wordpress/wp-includes/media.php(135): wp_constrain_dimensions()
    #1 /opt/bitnami/wordpress/wp-includes/media.php(268): image_constrain_size_for_editor()
    #2 /opt/bitnami/wordpress/wp-includes/media.php(970): image_downsize()
    #3 /bitnami/wordpress/wp-content/themes/uncode/core/inc/compatibility/rankmath/class-uncode-rankmath.php(88): wp_get_attachment_image_src()
    #4 /opt/bitnami/wordpress/wp-includes/class-wp-hook.php(324): Uncode_RankMath_Support->add_images_to_sitemap()
    #5 /opt/bitnami/wordpress/wp-includes/plugin.php(256): WP_Hook->apply_filters()
    #6 /bitnami/wordpress/wp-content/plugins/seo-by-rank-math/includes/traits/class-hooker.php(102): apply_filters_ref_array()
    #7 /bitnami/wordpress/wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/class-image-parser.php(135): RankMath\Sitemap\Image_Parser->do_filter()
    #8 /bitnami/wordpress/wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/providers/class-post-type.php(494): RankMath\Sitemap\Image_Parser->get_images()
    #9 /bitnami/wordpress/wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/providers/class-post-type.php(209): RankMath\Sitemap\Providers\Post_Type->get_url()
    #10 /bitnami/wordpress/wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/class-generator.php(169): RankMath\Sitemap\Providers\Post_Type->get_sitemap_links()
    #11 /bitnami/wordpress/wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/class-generator.php(135): RankMath\Sitemap\Generator->build_sitemap()
    #12 /bitnami/wordpress/wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/class-sitemap-xml.php(166): RankMath\Sitemap\Generator->get_output()
    #13 /bitnami/wordpress/wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/class-sitemap-xml.php(153): RankMath\Sitemap\Sitemap_XML->build_sitemap()
    #14 /bitnami/wordpress/wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/class-sitemap-xml.php(92): RankMath\Sitemap\Sitemap_XML->has_sitemap_in_cache()
    #15 /bitnami/wordpress/wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/class-sitemap-xml.php(82): RankMath\Sitemap\Sitemap_XML->output()
    #16 /bitnami/wordpress/wp-content/plugins/seo-by-rank-math/includes/modules/sitemap/class-router.php(79): RankMath\Sitemap\Sitemap_XML->__construct()
    #17 /opt/bitnami/wordpress/wp-includes/class-wp-hook.php(324): RankMath\Sitemap\Router->request_sitemap()
    #18 /opt/bitnami/wordpress/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #19 /opt/bitnami/wordpress/wp-includes/plugin.php(565): WP_Hook->do_action()
    #20 /opt/bitnami/wordpress/wp-includes/class-wp-query.php(1140): do_action_ref_array()
    #21 /opt/bitnami/wordpress/wp-includes/class-wp-query.php(1868): WP_Query->parse_query()
    #22 /opt/bitnami/wordpress/wp-includes/class-wp-query.php(3824): WP_Query->get_posts()
    #23 /opt/bitnami/wordpress/wp-includes/class-wp.php(696): WP_Query->query()
    #24 /opt/bitnami/wordpress/wp-includes/class-wp.php(816): WP->query_posts()
    #25 /opt/bitnami/wordpress/wp-includes/functions.php(1336): WP->main()
    #26 /opt/bitnami/wordpress/wp-blog-header.php(16): wp()
    #27 /opt/bitnami/wordpress/index.php(17): require(‘…’)
    #28 {main}
    thrown in /opt/bitnami/wordpress/wp-includes/media.php on line 467

    Line 476 in media.php refers to:

    if ( (int) round( $current_width * $larger_ratio ) > $max_width || (int) round( $current_height * $larger_ratio ) > $max_height ) {
    // The larger ratio is too big. It would result in an overflow.
    $ratio = $smaller_ratio;
    } else {
    // The larger ratio fits, and is likely to be a more “snug” fit.
    $ratio = $larger_ratio;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • I have found the issue. RankMath expects that all images contain a width and height attribute. I have provided one for every image and the issue is now resolved.

    Hello,

    We’re delighted to hear that this issue has been resolved. We appreciate your feedback.

    This ticket will be closed now, but if you ever have another question or need any help in the future, please don’t hesitate to create a new forum topic. We’ll be more than happy to assist you again.

    Thank you for choosing Rank Math and have a wonderful day!

Viewing 2 replies - 1 through 2 (of 2 total)

The ticket ‘page-sitemap.xml fatal error with ‘Images in Sitemaps’ option is enabled’ is closed to new replies.