Hello,
Can we consider an improvement of (file) to make it modern and user-friendly?
I will try to be as brief and quick as possible, this improvement requires a deep understanding of some technical aspects, a UI/UX improvement
It will be difficult to explain it by text only, for fear that no one will understand what we are talking about.
But I am sure that the devs or programmers behind this forum will very quickly see the potential or ideas to improve
For users it will be a pleasant surprise to see a modern uploader as they are used to seeing everywhere on the web in recent years.
So I will publish enough data and sources, images and concept made by figma to illustrate what this Modern Media Upload (File v2) should look like based on what we have already acquired and done by bricksforge
Just plan a good coffee / tea, a few minutes of reflection and observation (you will need it )
to start let’s look at what file already does
at first glance for someone normal everything is fine…
let’s try to see now our file v2…
how did we get to this? the following image will try to explain it in detail
Mobile view
concerning the options first image as featured image
I already use this technique with ACF and Pods
knowing that bricksforge at the time of writing these lines
cannot work with pods > file image and acf gallery field
as I am for the adoption of compatibility of (filev2) with these two plugins I put you the code snippet that I use to allow me to make this possibility work (backend)
of course as we have already seen above, the possibility of also allowing
“star to featured image”
it is better to make things simpler by adopting this approach or give the choice to have one or the other
for ACF
/**
* Sets the first image from a gallery field as the post thumbnail
*
* This function hooks into the `acf/save_post` filter and automatically sets
* the first image from a designated gallery field as the post thumbnail whenever
* a post is saved using the Advanced Custom Fields (ACF) plugin.
*
* @param int $post_id The ID of the post being saved
*/
function gallery_to_thumbnail($post_id) {
/**
* Get the value of the custom field named "gallery" from the post
*
* We use `get_field` function to retrieve the value of a custom field.
* The second argument is the post ID, and the third argument (`false`) ensures
* the returned value is not formatted.
*/
$gallery = get_field('gallery', $post_id, false);
/**
* Check if the gallery field is not empty
*
* This check ensures we only proceed if there are actually images in the gallery field.
*/
if (!empty($gallery)) {
/**
* Get the ID of the first image from the gallery array
*
* Since the gallery field likely holds an array of image IDs, we access the first element
* using the index `[0]`.
*/
$image_id = $gallery[0];
/**
* Set the retrieved image ID as the post thumbnail
*
* We use the `set_post_thumbnail` function to set the image with ID `$image_id` as the
* post thumbnail for the post with ID `$post_id`.
*/
set_post_thumbnail($post_id, $image_id);
}
}
for pods
// Define the CPT name (replace with your actual CPT name)
$my_cpt = 'property';
/**
* Update Featured Image on Post Save (Optimized)
*
* This function handles setting (or removing) the first image from a multi-select field
* as the featured image.
*
* It takes the following arguments:
* - $pieces: An array containing post data from Pods API.
* - $is_new_item: A boolean indicating if it's a new post.
* - $id: The ID of the post being saved.
* - $cpt_name: The name of the custom post type (CPT).
* - $featured_image_field_name: The field name containing the image attachments.
*
* @since 1.0.0
*/
add_action( 'pods_api_post_save_pod_item_' . $my_cpt, 'my_featured_image_update', 10, 5 );
function my_featured_image_update( $pieces, $is_new_item, $id, $cpt_name, $featured_image_field_name ) {
// Featured image field name (assuming multi-select, images only)
$featured_image_field_name = 'gallery';
// Process featured image (if applicable and enabled)
if ( array_key_exists( $featured_image_field_name, (array) $pieces['fields'] ) ) {
$images = $pieces['fields'][$featured_image_field_name]['value'];
// Check if there are any images in the gallery field
if ( !empty($images) && is_array($images) ) {
$attachment_id = array_keys( $images )[0];
set_post_thumbnail( $id, (int) $attachment_id );
} else {
// Check if a featured image is already set
$has_featured_image = has_post_thumbnail( $id );
if ( $has_featured_image ) {
delete_post_thumbnail( $id );
}
}
}
}
I now leave the place to the devs to express themselves on what are the obstacles that prevent us from achieving this
[Update]
I had almost forgotten it but it is almost essential that (file v2) but as the operation is not really like file v2 we will call it “profile pic”
this new widget is used to update the profile image
as you have already noticed at image 3 “edit profile”
it takes us to our edit profile page with the new “profile pic”
a real update profile image, I mean by a real one, one that we find on almost every site or the basic standard thing that everyone understands in 2 seconds
there are a hundred or even thousands of them but the operation is the same
a hover on the image to indicate the action, click on the image to update, an edit button to delete or edit / or x secondary task.
in my example I took the one from github
the rest is explained in the images
sources and inspirations