• Resolved rohitmanglik

    (@rohitmanglik)


    Hi WP All Import Team,

    I tried importing images in gallery. These images are downloaded inside my WordPress Installation i.e. I can see them in Media folder. When I clicked on individual image inside Media, in “Uploaded to” heading, it’s properly linked.

    However, when I view individual listing, images are not linked over there. Even on front end gallery images are not visible. Only one featured image comes in gallery.

    I created custom post type – Institute. I did not enter any value in Step 3: Custom Fields -> listing_gallery. Do I need to enter any serialized value over there? If yes, how to get URL of new paths (of downloaded images in my server)?

    • This topic was modified 8 years, 6 months ago by rohitmanglik.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter rohitmanglik

    (@rohitmanglik)

    Any help please?

    Plugin Author WP All Import

    (@wpallimport)

    Hi rohitmanglik.

    Our Inventor WP add-on only works with the listing types provided by the Inventor WP plugin, it would not work for any custom ones without you modifying it.

    The listing_gallery field is a serialized array that uses the image ID as the key and the URL as the value, for example: https://pastebin.com/dG270aYM. You will need to use our API to import this data: https://www.wpallimport.com/documentation/advanced/action-reference/

    Thread Starter rohitmanglik

    (@rohitmanglik)

    Thanks, this code did the work:

    <?php
    add_action('pmxi_gallery_image', 'my_gallery_image', 10, 3);
    function my_gallery_image($pid, $attid, $image_filepath) {
    	$listing_gallery = get_post_meta($pid, 'listing_gallery', $single = false);
    	$listing_gallery[$attid] = wp_get_attachment_url($attid);
    	$result = Array();
    	foreach ($listing_gallery as $key => $value) {
    		$key_in = $key;
    		$value_in = $value;
    		
    		if($key_in>0)
    			$result[$key_in] = $value_in;
    
    		while(is_array($value_in)) {
    				if(isset($value[0]))
    					$value = $value[0];
    				
    				foreach ($value as $key_inner => $value_inner) {
    					$key_in = $key_inner;
    					$value_in = $value_inner;
    					
    					if($key_in>0)
    						$result[$key_in] = $value_in;			
    				}
    			}
    		}
    		update_post_meta($pid, 'listing_gallery', $result);    
    	}
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Gallery Images are imported in Media but not properly linked’ is closed to new replies.