category image taxonomy

Found a solution:

<?php 
    $cat = get_the_category();
    $category_id = $cat[0]->term_id;


                foreach (get_the_category() as $cat) :




                $attachmentId = get_option("category_image_{$category_id}", 'null');
                $imageArr = wp_get_attachment_image_src( $attachmentId, 'medium' );     
                $imageURL = $imageArr[0];                                           
                echo '<img src="' .  $imageURL . '" />';

                endforeach; ?>