WordPress.org

Ready to get started?Download WordPress

Forums

Magic Fields 2
[resolved] output URL to image file (not original size) (5 posts)

  1. eastbank
    Member
    Posted 2 years ago #

    Hello, I'm using a field group that can be duplicated to create an image gallery. Using the magic field's thumbnail size as what is displayed on the page, I want that thumbnail to link to a larger version of the image (but not the original size).
    Is there a way to do this?

    http://wordpress.org/extend/plugins/magic-fields-2/

  2. eastbank
    Member
    Posted 2 years ago #

    I see that I can easily do what I'm asking if I just use a single field group, then give the image field within that group the ability to be duplicated. However, the re-ordering functionality is really needed and that's not an option when doing it that way.

    I'm using this method of outputting the duplicated field groups:

    <?php
           $members = get_order_group('members_name');
           foreach($members as $member){
           echo get_image('members_photo',$member);
           }
        ?>

    Which works great for outputting the thumbnail image...but I cannot figure out how to get it to output a URL to a custom sized image.

  3. eastbank
    Member
    Posted 2 years ago #

    So here's an update:
    I decided to try the code I have used to grab data from multiple field sets from the Custom Field Template plugin. This was successful, however, it only outputs the first and last groups....any ideas??

    <?php // retrieve entries with photo_gallery_image prefix
    				$sql = " SELECT * FROM $wpdb->postmeta	WHERE post_id = $post->ID AND meta_key LIKE '%photo_gallery_image%' ORDER BY meta_id ASC";
    				$data_objects = $wpdb->get_results($sql);
    				$project = array();
    				$i = 0;
    
    				foreach($data_objects as $data) {
    
    					// the name of the fieldset:
    					if($data->meta_key == 'photo_gallery_image') {
    						$limit = $data->meta_value;
    					}
    
    					$i = ( $i <= $limit ) ? $i : 1;
    
    					if( $data->meta_value != $limit ) {
    					$project[$i]["$data->meta_key"] = $data->meta_value;
    					}
    					$i++;
    				}
    				//check data
    				//print_r($project);
    
    				foreach( $project as $key){
    					?>
    
    <?php
    $attachment_id = $key['photo_gallery_image_gallery_image']; // attachment ID
    
    $image_attributes = wp_get_attachment_image_src( $attachment_id,'large','' ); // returns an array
    ?> 
    
    <li>
    <a class="group1" href="<?php echo $image_attributes[0]; ?>"><img src="<?php echo wp_get_attachment_thumb_url($key['photo_gallery_image_gallery_image']); ?>"/></a>
    </li>    
    
                        <?php
    					// etc....
    				} ?>
  4. hunk
    Member
    Plugin Author

    Posted 2 years ago #

    Hi, in get_image check param $tag_img,

    http://wiki.magicfields.org/doku.php?id=front-end_functions_v20#get_image

    echo get_image('photo_gallery_image',$my_group,$field_index,0); //this return the path of thumbnail

  5. eastbank
    Member
    Posted 2 years ago #

    You are my hero.

    Thank you so much for the quick reply!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic