{"id":9784646,"date":"2017-12-15T05:23:17","date_gmt":"2017-12-15T05:23:17","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/undefined-variable-placeholder_color\/"},"modified":"2017-12-15T05:23:17","modified_gmt":"2017-12-15T05:23:17","slug":"undefined-variable-placeholder_color","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/undefined-variable-placeholder_color\/","title":{"rendered":"Undefined variable: placeholder_color"},"content":{"rendered":"<p>I&#8217;ve started using this plugin to lazy load images, including a custom method my theme uses for featured images. I noticed this issue on an article that doesn&#8217;t have a featured image at all, but I think the issue might occur in other situations as well.<\/p>\n<p>In <code>\/wp-content\/plugins\/easy-lazy-loader\/easy-lazy-loader.php on line 652<\/code>, I get the error that <code>placeholder_color<\/code> is undefined.<\/p>\n<p>Here&#8217;s how the code appears to be working:<\/p>\n<pre><code>\n\/\/ use low res preview image as placeholder if applicable\nif ( &#039;lowres&#039; === $placeholder_type &amp;&amp; $img_id !== false ) {\n\t$tiny_img_data  = wp_get_attachment_image_src( $img_id, $this-&gt;OPTIONS[&#039;placeholder_image_size&#039;] );\n\t$tiny_url = $tiny_img_data[0];\n\t$placeholder_url_used = $tiny_url;\n}\n\/\/ use color as placeholder if applicable\nelse if ( &#039;color&#039; === $placeholder_type &amp;&amp; class_exists( &#039;WordPress_Gallery_Extra&#039; ) ) {\n\t$placeholder_color = &quot;&quot;;\n\n\tif( $img_id !== false ) {\n\t\t$placeholder_color = get_post_meta( $img_id, &#039;_wgextra_dominant_color&#039;, true );\n\t}\n\n\tif ( !$placeholder_color ) {\n\t\t$placeholder_color = $this-&gt;OPTIONS[&#039;default_image_placeholder_color&#039;];\n\t}\n\n\t$placeholder_url_used = self::create_placeholder( $placeholder_color, (int) $width, (int) $height, &#039;Image loading...&#039; );\n}\n\/\/ use transparent as placeholder if applicable\nelse if ( &#039;default&#039; === $placeholder_type &amp;&amp; !is_string( $width ) &amp;&amp; !is_string( $height ) ) {\n\t$placeholder_url_used = self::create_placeholder( $placeholder_color, (int) $width, (int) $height );\n}\n<\/code><\/pre>\n<p>If I understand correctly, <code>placeholder_color<\/code> is only defined if <code>WordPress_Gallery_Extra<\/code> exists, but even if it does not exist, the plugin attempts to use it:<\/p>\n<pre><code>\n\/\/ use transparent as placeholder if applicable\nelse if ( &#039;default&#039; === $placeholder_type &amp;&amp; !is_string( $width ) &amp;&amp; !is_string( $height ) ) {\n\t$placeholder_url_used = self::create_placeholder( $placeholder_color, (int) $width, (int) $height );\n}\n<\/code><\/pre>\n<p>It doesn&#8217;t seem like anything is keeping this placeholder method from being called, while looking for a color value that may not exist.<\/p>\n","protected":false},"template":"","class_list":["post-9784646","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9784646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9784646\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=9784646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}