Title: Image/Attachment URL
Last modified: August 31, 2016

---

# Image/Attachment URL

 *  [legius](https://wordpress.org/support/users/legius/)
 * (@legius)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/imageattachment-url/)
 * Hello Jonathan,
    is there a possibility to get as output value one of the following?–
   featured picture URL – attachment URL
 * Thanks for the answer!
    Best regards, Martin
 * [https://wordpress.org/plugins/query-wrangler/](https://wordpress.org/plugins/query-wrangler/)

Viewing 1 replies (of 1 total)

 *  [funlab](https://wordpress.org/support/users/funlab/)
 * (@funlab)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/imageattachment-url/#post-8496942)
 * I just did that!
    After struggling a while, I came up with a somewhat easy solution.
   Just added the code below at includes/fields/featured_image.php. But then this
   is no good if f I’m to update the plugin in the future, so I guess there might
   be a better place to add the code, like in your theme, or in the theme-customisations-
   master plugin, but I don’t really know how to make sure it’s loaded on time… 
   The code just duplicates the featured image field code, but replacing wp_get_attachment_image
   with wp_get_attachment_image_src:
 *     ```
       add_filter( 'qw_fields', 'qw_field_featured_image_url' );
       /*
        * Add field to qw_fields
        */
       function qw_field_featured_image_url( $fields ) {
   
       	$fields['featured_image_url'] = array(
       		'title'            => 'Featured Image URL',
       		'description'      => 'The "post_thumbnail" URL of a given row.',
       		'output_callback'  => 'qw_theme_featured_image_url',
       		'output_arguments' => TRUE,
       		'form_callback'    => 'qw_field_featured_image_url_form',
       	);
   
       	return $fields;
       }
       /*
        * Image attachment URL settings Form
        */
       function qw_field_featured_image_url_form( $field ) {
       	//$image_styles = _qw_get_image_styles();
       	$image_styles = get_intermediate_image_sizes();
       	?>
       	<p>
       		<label class="qw-label">Image Display Style:</label>
       		<select class='qw-js-title'
       		        name='<?php print $field['form_prefix']; ?>[image_display_style]'>
       			<?php
       			foreach ( $image_styles as $key => $style ) {
       				$style_selected = ( $field['values']['image_display_style'] == $style ) ? 'selected="selected"' : '';
       				?>
       				<option
       					value="<?php print $style; ?>" <?php print $style_selected; ?>><?php print $style; ?></option>
       			<?php
       			}
       			?>
       		</select>
       	</p>
       <?php
       }
   
       /*
        * Return the images URL
        *
        * @param $post
        * @param $field
        */
       function qw_theme_featured_image_url( $post, $field ) {
       	$style = $field['image_display_style'];
       	if ( has_post_thumbnail( $post->ID ) ) {
       		$image_id = get_post_thumbnail_id( $post->ID, $style );
       		return wp_get_attachment_image_src( $image_id, $style )[0];
       	}
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Image/Attachment URL’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/query-wrangler_4f534c.svg)
 * [Query Wrangler](https://wordpress.org/plugins/query-wrangler/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/query-wrangler/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/query-wrangler/)
 * [Active Topics](https://wordpress.org/support/plugin/query-wrangler/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/query-wrangler/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/query-wrangler/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [funlab](https://wordpress.org/support/users/funlab/)
 * Last activity: [9 years, 8 months ago](https://wordpress.org/support/topic/imageattachment-url/#post-8496942)
 * Status: not resolved