simply i want to remove <figcaption> from every image and remove text between <figcaption> tag' <figcaption class="blocks-gallery-item__caption">Image caption</figcaption>
I just want to get all atachment image from post with Alt, description, title, size, resotution and how to add DOWNLOAD button? i want to create image downloading website on wordpress for example LINK <?php $args = array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'numberposts' => -1, // show all 'post_status' => 'any', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC' ); $images = get_posts($args); if($images) { ?> <?php foreach($images as $image) { ?> <img src="<?php echo wp_get_attachment_url($image->ID); ?>" …
Is there a way to fetch the ALT/TITLE of ALL images in the media gallery? I think this would be an easy way for a website to have a Pictures page that just pulls all of the images from the media gallery, granted it would only be necessary in certain scenarios. I don't need instructions on how to create a Pictures page, just how to pull all of the image URLs. Thanks!
Well, we want to add the description field on the attached media under the post edit page. I have attached an image for reference. Explanation: Under posts, after adding an attachment if we click on the edit button to edit the details of the attached media we didn't find any description fields as we want to show the "Description" and also want to add the same facility to update that "Description" the same way we update captions and alt text …
How to customize the attachment image page with previous and next navigation button and show below rest images in a gallery ? I just added a visual representation Post page Attachment page
Following the approach in the developer docs for selected() but can't get it to work with a custom field in the media library for a select list. It won't save the value, or become "selected". Looks like WP is doing some js/ajax in the background here, so do I need to approach this differently or have a dumb typo? Please see code below, help is appreciated. /* Add license field to media attachments */ function add_custom_field_license( $form_fields, $post ) { …
I have the following code in a self-written plugin. In the function saveHomepageGalleryCheckbox the first param ($post) is always null. Did I something wrong? The second parameter ($attachment) has the correct value. Wordpress Version: 5.3.2 PHP Version: 7.3.15 Code: class MediaView { private $key = 'include_in_homepage_gallery'; public function __construct() { add_filter('attachment_fields_to_edit', [$this, 'renderHomepageGalleryCheckbox'], 10, 2); add_filter('attachment_fields_to_save', [$this, 'saveHomepageGalleryCheckbox'], 10, 2); } public function renderHomepageGalleryCheckbox(array $fields, WP_Post $post) { $meta = get_post_meta($post->ID, $this->key, true); $checked = (boolval($meta) === true) ? 'checked="checked"' …
I've got a few ACF Image fields for posts And I want to only query the images in the media library browser already uploaded and used on the current post. In other words, when opening the media library in a image field I only want to see the images of this post. This is what I came up with. But it doesn't work. I can upload a image to one field Then in second field I don't see the image …
In the EU it will shortly be a requirement for public sector websites to have alt text for uploaded images. My organisation's users are rubbish at adding alt text, however, and I'm trying to find a way to force them to do so. The only way I've come across so far is to automatically fill the alt text with the image's title - which is not great if an image is called "shutterstock_45363627" - and could encourage laziness. Ways I …
I'm trying to use the attachment_fields_to_edit hook to create new fields on media attachments. According to the new documentation, one of the parameters is an "array of attachment form fields". I can't find, however, where on the documentation are the specs on how to build this array. I found this page on the Codex, but the provided example uses only value, label and helps. I found a few more parameters in the source of get_attachment_fields_to_edit, such as input and html, …
I have a front end post form that lets users upload multiple photos and on there I have 2 input fields to try and save custom meta data for each attachment - $vid_pix = get_post_meta($v_Id, 'vid_pix', false); if (!empty($vid_pix)) { foreach ($vid_pix as $vP) { $Pt = get_post_meta($vP, 'photo_time', true); $Por = get_post_meta($vP, 'photo_order', true); echo '<img src="' . wp_get_attachment_thumb_url($vP) . '" alt=""/>'; echo '<input type="hidden" name="photo_order" class="photo_order" value="'.$Por.'" />'; echo '<input type="text" name="photo_time" class="photo_time" value="'.$Pt.'"/>'; } } When the …
I am developing my plugin to add a custom attachment fields. I used attachment_fields_to_edit filter (https://codex.wordpress.org/Plugin_API/Filter_Reference/attachment_fields_to_edit) to resolve my mission. However, when I go the attachment form page, it shows a field "Required fields are marked *". You can have a look at below picture. Edit: added my soure code function my_add_attachment_location_field( $form_fields, $post ) { $field_value = get_post_meta( $post->ID, 'location', true ); $form_fields['location'] = array( 'value' => $field_value ? $field_value : '', 'label' => __( 'Location' ), 'helps' => …
I've added a custom meta field to my image details so that a client can add a number to their photos (a design choice). The data would need to show up under each image (like a caption) inserted into the editor when the user inserts into post (I can't use the caption for my purposes because WordPress won't let me nest shortcodes, and I'm using a grid columns plugin which relies on shortcodes). Found out that you can indeed nest …
I added few custom fields via attachment_fields_to_edit and would like to show them only when certain theme or page builder image option opens the wp.media.iframe. Currently they are visible regardless what button opens the uploader for example post "Add media" would not have any use for this option So I am kinda trying to find a "hook" that would let me know what option is currently using the uploader. What I am trying to stay away from is doc click …
I'm using WP 4.1.1 and trying to create a default value for the 'Alt text' when uploading an image (dropping it straight into post and dialog appears). I've tried doing this with this hook https://codex.wordpress.org/Plugin_API/Filter_Reference/attachment_fields_to_edit and while I seem to be able to ADD a new field (it appears on the dialog form), I cannot modify the value of the 'Alt Text' field. So the following does NOT work (but should, according to the docs!). I have tried changing the …
I'm trying to create a custom field in ATTACHMENT DETAILS section. I want to add in this field multiply words separated by space which will be than added as a classes to particular images. This is the solution I've found so far. It adds custom field but it doesn't add a class to images. What is wrong here? function add_attachment_classes_field( $form_fields, $post ) { $field_value = get_post_meta( $post->ID, 'classes', true ); $form_fields['classes'] = array( 'value' => $field_value ? $field_value : …
I'd like to add two custom text fields for image attachments to posts (images inserted into the content of a post). Second I'd also like to remote some of the default fields like caption and description. I've managed to add fields like so: add_filter('attachment_fields_to_edit', array($this, 'applyFilter'), 1, 2); public function applyFilter( $form_fields, $post = null ) { $form_fields['someCustom'] = array( 'label' => 'Image credit', 'input' => 'text', 'helps' => 'Photographer / bureau', 'application' => 'image', 'exclusions' => array( 'audio', 'video' …
I've been doing a lot of research and I've yet to work this out. Can you add in a custom option in the Attachment Display Settings (part of Insert Media dialog in post editor)? What I'm after is the ability to add an anchor with a class around all images in posts.
I am writing a plugin for adding a custom field to the image attachment dialogue box, the plugin works for storing valid input data. I have a problem for showing the error message "This is not a valid URL". I think that I followed the documentation correctly but maybe there is something that I still missing. class my_plugin { public function __construct( ) { $this->url_pattern = "/^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?" . "([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|" . "%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]" . "|%[a-fA-f\d]{2,2})*)?$/"; add_filter("attachment_fields_to_edit", array($this, "videourl_image_attachment_fields_to_edit"), 10, 4); add_filter("attachment_fields_to_save", array($this, …