src/properties/class-papi-property-file.php
public function format_value( $value, $slug, $post_id ) {
		if ( ! is_array( $value ) ) {
			$value = $this->get_file( $value );
		}

		// Single file.
		if ( is_numeric( $value ) ) {
			$meta = wp_get_attachment_metadata( $value );

			if ( isset( $meta ) && ! empty( $meta ) ) {
				$att  = get_post( $value );
				$mine = [
					'alt'         => trim( strip_tags( get_post_meta( $value, '_wp_attachment_image_alt', true ) ) ),
					'caption'     => trim( strip_tags( $att->post_excerpt ) ),
					'description' => trim( strip_tags( $att->post_content ) ),
					'id'          => intval( $value ),
					'is_image'    => (bool) wp_attachment_is_image( $value ),
					'title'       => esc_html( $att->post_title ),
					'url'         => wp_get_attachment_url( $value ),
				];

				$meta = is_array( $meta ) ? $meta : ['file' => $meta];

				if ( isset( $meta['sizes'] ) ) {
					foreach ( array_keys( $meta['sizes'] ) as $size ) {
						if ( $src = wp_get_attachment_image_src( $mine['id'], $size ) ) {
							$meta['sizes'][$size]['url'] = $src[0];
						}
					}
				}

				$value = (object) array_merge( $meta, $mine );

				if ( ! papi_is_admin() && $this->get_setting( 'fields' ) === 'ids' ) {
					return $this->get_file_value( $value );
				}

				return $value;
			}

			return (int) $value;
		}

		// Multiple files.
		if ( is_array( $value ) ) {
			foreach ( $value as $k => $v ) {
				$value[$k] = $this->format_value( $v, $slug, $post_id );
			}

			return $value;
		}

		if ( is_object( $value ) && ! isset( $value->url ) ) {
			return;
		}

		return $value;
	}
public function format_value( $value, $slug, $post_id ) {
		if ( ! is_array( $value ) ) {
			$value = $this->get_file( $value );
		}

		// Single file.
		if ( is_numeric( $value ) ) {
			$meta = wp_get_attachment_metadata( $value );

			if ( isset( $meta ) && ! empty( $meta ) ) {
				$att  = get_post( $value );
				$mine = [
					'alt'         => trim( strip_tags( get_post_meta( $value, '_wp_attachment_image_alt', true ) ) ),
					'caption'     => trim( strip_tags( $att->post_excerpt ) ),
					'description' => trim( strip_tags( $att->post_content ) ),
					'id'          => intval( $value ),
					'is_image'    => (bool) wp_attachment_is_image( $value ),
					'title'       => esc_html( $att->post_title ),
					'url'         => wp_get_attachment_url( $value ),
				];

				$meta = is_array( $meta ) ? $meta : ['file' => $meta];

				if ( isset( $meta['sizes'] ) ) {
					foreach ( array_keys( $meta['sizes'] ) as $size ) {
						if ( $src = wp_get_attachment_image_src( $mine['id'], $size ) ) {
							$meta['sizes'][$size]['url'] = $src[0];
						}
					}
				}

				$value = (object) array_merge( $meta, $mine );

				if ( ! papi_is_admin() && $this->get_setting( 'fields' ) === 'ids' ) {
					return $this->get_file_value( $value );
				}

				return $value;
			}

			return (int) $value;
		}

		// Multiple files.
		if ( is_array( $value ) ) {
			foreach ( $value as $k => $v ) {
				$value[$k] = $this->format_value( $v, $slug, $post_id );
			}

			return $value;
		}

		if ( is_object( $value ) && ! isset( $value->url ) ) {
			return;
		}

		return $value;
	}
Format the value of the property before it's returned
to WordPress admin or the site.

@param  mixed  $value
@param  string $slug
@param  int    $post_id

@return mixed