• Resolved lucilec

    (@lucilec)


    Hi,
    First I’d like to thank you for this plugin. Exactly what I needed.
    In order to display more information in the popup, I’d like to display an “additional image”.
    I’ve tried different solution such as :
    1 – Add an image field with ACF in Marker
    2 – Add a additional field project_image
    3 – Fill this new field in my marker settings with the code given by ACF doc to display this image

    Could you lead me to the solution ?
    Thank you very much

    • This topic was modified 4 years, 10 months ago by lucilec.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author dgamoni

    (@dgamoni)

    Hi
    Thanks for using the plugin

    1 Add an image field with ACF in Marker
    https://prntscr.com/so0du3

    2 upload image to ACf in marker
    https://prntscr.com/so0hnq

    3 create custom tag, add to functions.php this code
    see doc https://locateandfilter.monothemes.com/docs/locateandfilter-wp-plugin/developers-guide/add-new-custom-tags/

    Locate_And_Filter_Addon_Helper::define_custom_tags( 
      array( 'project_image' =>'project_image'),
      'all', getDataCallbackFn_place_tags,
      'project_image'
    );
    function getDataCallbackFn_place_tags( $field, $id){
    	$html = '';
    	ob_start();
    
    		$project_image = get_field('project_image', $id);
    		echo  '<a href="'.$project_image.'"><img src="'.$project_image.'" style="width:300px;">';
    		
    	$html .= ob_get_contents();
    	ob_end_clean();
     
        return $html;   
    }

    4 add to tooltip this tag https://prntscr.com/so10ia
    see demo https://locateandfilter.monothemes.com/demo-map-for-post-by-filter-categories-and-tags-default-left-layout/
    https://prntscr.com/so126l

    I hope this helps

    Thread Starter lucilec

    (@lucilec)

    Thanks you very much for your so quick answer.
    As I’m using Oxygen builder, I have no functions.php
    And when I use your code as a plugin I get an error in the first line.
    Do you know why it doesn’t actually work in this case ?
    Thank again

    Plugin Author dgamoni

    (@dgamoni)

    add to your custom plugin this code, it works for me

    add_action('plugins_loaded', 'init_tags_for_locate_and_filter_plugin');
    function init_tags_for_locate_and_filter_plugin() {
      
      if ( class_exists('Locate_And_Filter_Addon_Helper') ) {
       
       		new Locate_And_Filter_Addon_Helper;
    
    		Locate_And_Filter_Addon_Helper::define_custom_tags( 
    		  array( 'project_image' =>'project_image'),
    		  'all', getDataCallbackFn_place_tags,
    		  'project_image'
    		);
    		function getDataCallbackFn_place_tags( $field, $id){
    			$html = '';
    			ob_start();
    
    				$project_image = get_field('project_image', $id);
    				echo  '<a href="'.$project_image.'"><img src="'.$project_image.'" style="width:300px;">';
    				
    			$html .= ob_get_contents();
    			ob_end_clean();
    		 
    		    return $html;   
    		}
    
      } else {
        add_action('admin_notices', 'wc_not_loaded');
      }
    }
    
    function wc_not_loaded() {
        printf(
          '<div class="error"><p>%s</p></div>',
          __('Sorry cannot create tag because Locate_And_Filter is not loaded')
        );
    }
    Thread Starter lucilec

    (@lucilec)

    Works perfectly! Thanks for your support

    Plugin Author dgamoni

    (@dgamoni)

    Closed

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Additional fields as an image’ is closed to new replies.