File Un-Attach
how to make multiple attachments to work (5 posts)

  1. zulfi1888
    Posted 3 years ago #

    I am trying with the helper function here http://wordpress.org/support/topic/plugin-file-un-attach-not-sure-that-multiple-attachments-is-working-properly?replies=8, but couldn't succeed. I am not good in coding and i got another plugin called file un-attach helper functions, i couldn't understand what to do next. I really need this to work because my attachments are showing on all posts in edit mode (inside gallery), but not showing when viewing as viewer. Can you help this??


  2. jamin84
    Posted 3 years ago #

    I'm in the same boat as everyone that is having trouble getting this to work with 3.5. I'm using WP-Property plugin (which uses the standard WP media gallery) and was only getting the last post to display an image assigned to multiple posts.

    I see the author added the code from Sebmeric, but it wasn't working without manually referencing and even then the format wasn't useful. I've gone through and updated so the format matches that from the media gallery.

    $gallery  = ($post->gallery)?$post->gallery:$property['gallery'];
    	  //get the attachements via Sebmeric's addition
    	  $fun = fun_get_attachments( array( 'post_mime_type' => 'image/jpeg' ) );
    	  foreach( $fun as $f){
    		$i['post_title'] = $f->post_title;
    		$i['post_excerpt'] = $f->post_excerpt;
    		$i['post_content'] = $f->post_content;
    		$i['attachment_id'] = $f->ID;
    		//get the image links for all the sizes
    		foreach (get_intermediate_image_sizes() as $s) {
    			$img = wp_get_attachment_image_src( $f->ID, $s );
    			$i[$s] = $img[0];
    		$m[$f->post_title] = $i;
    	  $gallery = ($m)?$m:$gallery;

    Obviously I'd like to avoid a foreach within a foreach, but it works. Hopes this helps :)

  3. kasiao
    Posted 3 years ago #

    Hello jamin, I don't have a lot of experience with php but I'd like to use your code. Can you tell me how I should insert it into my site? Should I add it to Sebmeric's plugin or to file-un-attach? If it's the latter- to which php function should I add it to? Finally, how can I call the appropriate function from a page? Thanks!

  4. Hax
    Plugin Author

    Posted 3 years ago #


    If you are using the [gallery] shortcode it will work by default, be sure that you don't set the id option [gallery id=""]

  5. kasiao
    Posted 3 years ago #

    Hello, I'm actually using a theme ( portfolio2 ) that doesn't use the gallery shortcode but rather calls a page's attachments directly.

    Can you explain how/where I should insert it jamin's code into my site? Should I add it to Sebmeric's plugin or to file-un-attach (as it stands Seberic's helper plugin crashes my site)?


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • File Un-Attach
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic