Title: TypeError: Unsupported operand types: string * float
Last modified: September 15, 2022

---

# TypeError: Unsupported operand types: string * float

 *  Resolved [rlamb2](https://wordpress.org/support/users/rlamb2/)
 * (@rlamb2)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/typeerror-unsupported-operand-types-string-float/)
 * We’re getting a lot of errors on a page during and after saving and I’ve managed
   to track it down to the custom image size functionality.
 *     ```
       PHP Fatal error:  Uncaught TypeError: Unsupported operand types: string * float in /site-path/wp-includes/media.php:467
       Stack trace:
       #0 /site-path/wp-includes/media.php(714): wp_constrain_dimensions('1000', '', 300)
       #1 /site-path/wp-includes/media.php(1376): wp_image_matches_ratio(300, 300, '1000', '')
       #2 /site-path/wp-includes/media.php(1067): wp_calculate_image_srcset(Array, 'https://www.sit...', Array, 46296)
       #3 /site-path/wp-content/plugins/elementor/includes/controls/groups/image-size.php(108): wp_get_attachment_image(46296, 'square-sm', false, Array)
       #4 /site-path/wp-content/plugins/elementor/includes/controls/groups/image-size.php(156): Elementor\\Group_Control_Image_Size::get_attachment_image_html(Array, 'image', 'image')
       #5 /site-path/wp-content/plugins/elementor/includes/widgets/image.php(701): Elementor\\Group_Control_Image_Size::print_attachment_image_html(Array)
       #6 /site-path/wp-content/plugins/elementor/includes/base/controls-stack.php(2223): Elementor\\Widget_Image->render()
       #7 /site-path/wp-content/plugins/elementor/includes/base/widget-base.php(609): Elementor\\Controls_Stack->render_by_mode()
       #8 /site-path/wp-content/plugins/elementor/includes/base/widget-base.php(750): Elementor\\Widget_Base->render_content()
       #9 /site-path/wp-content/plugins/elementor/includes/base/element-base.php(447): Elementor\\Widget_Base->print_content()
       #10 /site-path/wp-content/plugins/elementor/includes/base/element-base.php(787): Elementor\\Element_Base->print_element()
       #11 /site-path/wp-content/plugins/elementor/includes/base/element-base.php(447): Elementor\\Element_Base->print_content()
       #12 /site-path/wp-content/plugins/elementor/includes/base/element-base.php(787): Elementor\\Element_Base->print_element()
       #13 /site-path/wp-content/plugins/elementor/includes/base/element-base.php(447): Elementor\\Element_Base->print_content()
       #14 /site-path/wp-content/plugins/elementor/core/base/document.php(1627): Elementor\\Element_Base->print_element()
       #15 /site-path/wp-content/plugins/elementor/core/base/document.php(1078): Elementor\\Core\\Base\\Document->print_elements(Array)
       #16 /site-path/wp-content/plugins/elementor/includes/frontend.php(1092): Elementor\\Core\\Base\\Document->print_elements_with_wrapper(Array)
       #17 /site-path/wp-content/plugins/elementor/includes/frontend.php(1006): Elementor\\Frontend->get_builder_content(24)
       #18 /site-path/wp-includes/class-wp-hook.php(307): Elementor\\Frontend->apply_builder_in_content('<a href="https:...')
       #19 /site-path/wp-includes/plugin.php(189): WP_Hook->apply_filters('<a href="https:...', Array)
       #20 /site-path/wp-includes/post-template.php(253): apply_filters('the_content', '<a href="https:...')
       #21 /site-path/wp-content/themes/hello-elementor/template-parts/single.php(24): the_content()
       #22 /site-path/wp-includes/template.php(772): require('/nas/content/li...')
       #23 /site-path/wp-includes/template.php(716): load_template('/nas/content/li...', false, Array)
       #24 /site-path/wp-includes/general-template.php(204): locate_template(Array, true, false, Array)
       #25 /site-path/wp-content/themes/site/index.php(23): get_template_part('template-parts/...')
       #26 /site-path/wp-includes/template-loader.php(106): include('/nas/content/li...')
       #27 /site-path/wp-blog-header.php(19): require_once('/nas/content/li...')
       #28 /site-path/index.php(17): require('/nas/content/li...')
       #29 {main}
         thrown in /site-path/wp-includes/media.php on line 467, referer: https://www.google.com/
       ```
   
 * That error shows up in logs multiple times. Every time it does, the page with
   a custom image can’t load. The attachment on that page with a custom image size
   has `wp_attachment_metadata` like this:
 * > `a:5:{s:5:"width";i:1580;s:6:"height";i:1419;s:4:"file";s:40:"image0000000000000000-
   > e1660655486567.png";s:5:"sizes";a:13:{s:6:"medium";a:4:{s:4:"file";s:48:"image0000000000000000-
   > e1660655486567-600x539.png";s:5:"width";i:600;s:6:"height";i:539;s:9:"mime-
   > type";s:9:"image/png";}s:5:"large";a:4:{s:4:"file";s:49:"image0000000000000000-
   > e1660655486567-1024x920.png";s:5:"width";i:1024;s:6:"height";i:920;s:9:"mime-
   > type";s:9:"image/png";}s:9:"thumbnail";a:4:{s:4:"file";s:48:"image0000000000000000-
   > e1660655486567-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-
   > type";s:9:"image/png";}s:12:"medium_large";a:4:{s:4:"file";s:48:"image0000000000000000-
   > e1660655486567-768x690.png";s:5:"width";i:768;s:6:"height";i:690;s:9:"mime-
   > type";s:9:"image/png";}s:9:"1536x1536";a:4:{s:4:"file";s:50:"image0000000000000000-
   > e1660655486567-1536x1379.png";s:5:"width";i:1536;s:6:"height";i:1379;s:9:"mime-
   > type";s:9:"image/png";}s:8:"square-1";a:4:{s:4:"file";s:48:"image0000000000000000-
   > e1660655486567-600x600.png";s:5:"width";i:600;s:6:"height";i:600;s:9:"mime-
   > type";s:9:"image/png";}s:9:"square-sm";a:4:{s:4:"file";s:48:"image0000000000000000-
   > e1660655486567-300x300.png";s:5:"width";i:300;s:6:"height";i:300;s:9:"mime-
   > type";s:9:"image/png";}s:4:"hero";a:4:{s:4:"file";s:49:"image0000000000000000-
   > e1660655486567-1580x650.png";s:5:"width";i:1580;s:6:"height";i:650;s:9:"mime-
   > type";s:9:"image/png";}s:6:"hero-2";a:4:{s:4:"file";s:49:"image0000000000000000-
   > e1660655486567-1580x285.png";s:5:"width";i:1580;s:6:"height";i:285;s:9:"mime-
   > type";s:9:"image/png";}s:11:"rectangle-1";a:4:{s:4:"file";s:49:"image0000000000000000-
   > e1660655486567-1250x715.png";s:5:"width";i:1250;s:6:"height";i:715;s:9:"mime-
   > type";s:9:"image/png";}s:22:"elementor_custom_1000x";a:4:{s:4:"file";s:100:"
   > elementor/thumbs/image0000000000000000-e1660655486567-ptcm6medbaeeyeubhlaq2jas05bfh4djloprt7gv84.
   > png";<strong>s:5:"width";s:4:"1000";s:6:"height";s:0:""</strong>;s:9:"mime-
   > type";s:9:"image/png";}s:24:"elementor_custom_200x200";a:4:{s:4:"file";s:85:"
   > elementor/thumbs/image0000000000000000-pt6fm9eotlx6xjdr358fscz45y10vwx18oukv6wvkg.
   > png";s:5:"width";i:200;s:6:"height";i:200;s:9:"mime-type";s:9:"image/png";}
   > s:21:"elementor_custom_200x";a:4:{s:4:"file";s:100:"elementor/thumbs/image0000000000000000-
   > e1660655486567-ptcm6me3kg7hr4aquvt1er7ys780e6h9b7z2tnups8.png";<strong>s:5:"
   > width";s:3:"200";s:6:"height";s:0:""</strong>;s:9:"mime-type";s:9:"image/png";}}
   > s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";
   > s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";
   > s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:
   > 1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}`
 * Did some digging and it appears that in `elementor/includes/managers/image.php`
   a regex is pulling width and height out of a custom image size name, then feeding
   that directly into the array that goes into the database.
 * The problem seems to be that it’s inserting strings there, and not converting
   to numbers.
 * Site’s running Elementor 3.7.1 right now and PHP 8.0 as of last week, so maybe
   it’s a little more strict with the variable types than it used to be. Or maybe
   WP Engine has a weird PHP configuration. Either way, lines 96 and 97 might just
   need a couple quick `(int)`s inserted in there to make sure it’s never sending
   in strings.
 * Thanks!
    -  This topic was modified 3 years, 9 months ago by [rlamb2](https://wordpress.org/support/users/rlamb2/).
    -  This topic was modified 3 years, 9 months ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).

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

 *  [Elementor Team](https://wordpress.org/support/users/michellei/)
 * (@michellei)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/typeerror-unsupported-operand-types-string-float/#post-15937529)
 * Hi, since this seems like a bug with the server settings, may opt to visit our
   Github account where you may get in contact with a member of our development 
   team to query this.
    Please note that this is not an official support channel
   but a respective member of the development team will respond to your post as 
   soon as they are available. Please follow this guide which outlines the steps
   required to post on our Github: [https://github.com/elementor/elementor/blob/master/.github/CONTRIBUTING.md](https://github.com/elementor/elementor/blob/master/.github/CONTRIBUTING.md)
 *  Thread Starter [rlamb2](https://wordpress.org/support/users/rlamb2/)
 * (@rlamb2)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/typeerror-unsupported-operand-types-string-float/#post-15939465)
 * Apologies, I haven’t been in my email all weekend.
 * It was happening with my client’s remote site as well as on my local homebrew
   setup with almost no adjustment, so I don’t think it has anything to do with 
   server configuration, though I will check out that Github repo to see if there’s
   anything in there that can help.
 * What I ended up doing was manually fixing the dozen or so `_wp_attachment_metadata`
   serialized values that had strings where numbers should be and (educatedly stupid,
   I already know) adding `(int)` to those lines in the Elementor plugin, hoping
   a fix was coming in the next update.
 * Seems as though it didn’t, so I’ll need to apply that fix again.
 * As for steps to reproduce it, it seems to be from using a custom image size. 
   That’s it. Elementor stashes the custom image size as part of the available sizes
   for that attachment, and because the regex pulls them out of the `elementor_custom_###
   x###` image size name as strings that get sent directly into that serialized 
   array, when WordPress functions try to compare requested sizes (being actual 
   numbers) with known sizes (now sometimes being strings), it throws type errors.
 * I see the Repo already has [an issue](https://github.com/elementor/elementor/issues/19546)
   open for this too, so I’ll probably end up dropping some of these notes over 
   there as well.

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

The topic ‘TypeError: Unsupported operand types: string * float’ is closed to new
replies.

 * ![](https://ps.w.org/elementor/assets/icon-256x256.gif?rev=3444228)
 * [Elementor Website Builder - more than just a page builder](https://wordpress.org/plugins/elementor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/elementor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/elementor/)
 * [Active Topics](https://wordpress.org/support/plugin/elementor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/elementor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/elementor/reviews/)

 * 3 replies
 * 4 participants
 * Last reply from: [rlamb2](https://wordpress.org/support/users/rlamb2/)
 * Last activity: [3 years, 9 months ago](https://wordpress.org/support/topic/typeerror-unsupported-operand-types-string-float/#post-15939465)
 * Status: resolved