<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Evgeni Dimitrov on Medium]]></title>
        <description><![CDATA[Stories by Evgeni Dimitrov on Medium]]></description>
        <link>https://medium.com/@gentec?source=rss-ad08b7905e37------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*SVgRkLIOZh2938rF</url>
            <title>Stories by Evgeni Dimitrov on Medium</title>
            <link>https://medium.com/@gentec?source=rss-ad08b7905e37------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 22:04:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gentec/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Loading Custom Image Sizes in WP Block MediaPlaceholder Component]]></title>
            <link>https://medium.com/@gentec/loading-custom-image-sizes-in-wp-block-mediaplaceholder-component-168a15bc6ef1?source=rss-ad08b7905e37------2</link>
            <guid isPermaLink="false">https://medium.com/p/168a15bc6ef1</guid>
            <category><![CDATA[wordpress-blocks]]></category>
            <category><![CDATA[wordpress-block-editor]]></category>
            <dc:creator><![CDATA[Evgeni Dimitrov]]></dc:creator>
            <pubDate>Tue, 16 Sep 2025 07:25:07 GMT</pubDate>
            <atom:updated>2025-09-16T07:25:07.510Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GGK5wosKUdx_-CGu" /><figcaption>Photo by <a href="https://unsplash.com/@dengxiangs?utm_source=medium&amp;utm_medium=referral">Deng Xiang</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Working with images in WordPress blocks has become an almost daily part of the development process for most block developers. Whether you’re building custom blocks for clients or contributing to existing block libraries, handling image functionality is practically unavoidable. However, there’s a subtle but important gotcha that many developers encounter when working with the MediaPlaceholder component.</p><p>The issue revolves around custom image sizes. While WordPress allows you to register custom image sizes using add_image_size(), the default MediaPlaceholder component doesn&#39;t automatically recognize or load these custom registered sizes. This can be frustrating when you&#39;ve carefully defined specific dimensions for your block&#39;s image requirements, only to find that users can&#39;t select those sizes from the media library interface.</p><p>The MediaPlaceholder component, which provides the familiar “Select Media” interface in the block editor, relies on a specific set of image size data that needs to be explicitly made available to the JavaScript context. Without this additional step, your custom image sizes remain invisible to the block editor, even though they exist and are properly registered on the PHP side.</p><p>To resolve this, you’ll need to bridge the gap between your PHP-registered image sizes and the block editor’s JavaScript environment.</p><p>This small but crucial step ensures that content creators have access to all the image sizing options you’ve carefully planned for your blocks, creating a more seamless and professional editing experience.</p><pre>&lt;MediaPlaceholder<br>   onSelect={<br>      (image) =&gt; {<br>         // Set basic image attributes with fallbacks<br>         setAttributes({<br>            imageID: image?.id || null,<br>            imageAlt: image?.alt || &#39;&#39;,<br>            imgCaption: image?.caption || &#39;&#39;,<br>            imgDescription: image?.description || &#39;&#39;,<br>         });<br><br>         // Only proceed with API fetch if we have a valid image ID<br>         if (!image?.id) return;<br><br>         wp.apiFetch({<br>            path: `/wp/v2/media/${image.id}`<br>         }).then((fullMediaData) =&gt; {<br>            // Use optional chaining to safely access nested properties<br>            const customSize = fullMediaData?.media_details?.sizes?.[&#39;your_size_here&#39;];<br>            const fullSize = fullMediaData?.media_details?.sizes?.full;<br>            <br>            // Fallback hierarchy: custom size -&gt; full size -&gt; original image URL<br>            const imageUrl = customSize?.source_url || <br>                           fullSize?.source_url || <br>                           image?.url || <br>                           &#39;&#39;;<br><br>            setAttributes({ imageUrl });<br>         }).catch((error) =&gt; {<br>            // Fallback to original image URL if API call fails<br>            console.warn(&#39;Failed to fetch media details:&#39;, error);<br>            setAttributes({ imageUrl: image?.url || &#39;&#39; });<br>         });<br>      }<br>   }<br>   allowedTypes={[&#39;image&#39;]}<br>   multiple={false}<br>   labels={{ title: &#39;Select Image&#39; }}<br>/&gt;</pre><p>wp.apiFetch returns a promise so you will have to wait for it’s response and set the imageUrl property in attributes once the response comes back. This component now features optional chaining and fallback to default sizes if your custom one cannot be loaded.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=168a15bc6ef1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Passing Data From Parent To Child Component In React]]></title>
            <link>https://medium.com/@gentec/passing-data-from-parent-to-child-component-in-react-c321a118ccb4?source=rss-ad08b7905e37------2</link>
            <guid isPermaLink="false">https://medium.com/p/c321a118ccb4</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Evgeni Dimitrov]]></dc:creator>
            <pubDate>Tue, 21 Mar 2023 17:17:37 GMT</pubDate>
            <atom:updated>2023-03-21T17:17:37.111Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qiRTBATKa-MtyWWbW-ALEg.jpeg" /></figure><p>When you start your journey with React, especially if you have previous experience with libraries like Vue.js, one of the first questions you are going to encounter is how to pass method from parent to child.</p><p>What you really need to do is to “export” reference of the parent method to the child as a prop.</p><pre>import React from &#39;react&#39;;<br><br>export class Parent extends React.Component{<br><br>    parentMethod(param)<br>    {<br>      alert(&#39;I am parent method!&#39;);<br>    }<br><br>    render() {<br>    return (<br>     &lt;div&gt;<br>      &lt;Child parentMethod={param =&gt; this.parentMethod(param)}&gt;&lt;/Child&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}<br><br>export default Parent;</pre><p>Here we are exporting method called “parentMethod” to the child component. It is important to notice that we’re sending only 1 parameter, if we need to export additional parameters the syntax changes to this:</p><pre>import React from &#39;react&#39;;<br><br>export class Parent extends React.Component{<br><br>    parentMethod(param1, param2)<br>    {<br>      alert(&#39;I am parent method!&#39;);<br>    }<br><br>    render() {<br>    return (<br>     &lt;div&gt;<br>      &lt;Child parentMethod={(param1,param2) =&gt; this.parentMethod(param1,param2)}&gt;&lt;/Child&gt;<br>      &lt;/div&gt;<br>    );<br>  }<br>}<br><br>export default Parent;</pre><p>Now, let’s review the Child component.</p><pre>import React from &#39;react&#39;;<br><br>export class Child extends React.Component{<br>    constructor(props) {<br>    super(props);<br>   }<br><br>   render(){<br>    return (<br>      &lt;a href=&quot;javascript:void(0)&quot; onClick={(param1,param2) =&gt; this.props.parentMethod(param1,param2)}&gt;up&lt;/a&gt; | <br>    )<br>  }<br>}<br><br>export default Child;</pre><p>So what you can see here is that the parent method has been passed to the child as a prop.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c321a118ccb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>