You can use some JavaScript to add a quick validation that checks the file type when someone tries to add an image. Place this script in your theme’s main JS file or inline in your functions.php
.
Here’s a snippet of JavaScript to give you an idea:
jQuery(document).ready(function($) {
wp.customize.control('themeslug_logo', function(control) {
control.uploader.params.allowed_extensions = ['png'];
control.container.on('click keydown', '.upload-button', function() {
control.uploader.uploader.plupload.uploader.settings.filters.mime_types = [{title: 'Allowed Files', extensions: 'png'}];
});
});
});
This will limit the media uploader to only show PNG files when someone tries to upload an image for your logo setting in the Customizer.
Give that a shot and let us know how it works for you! 😊
Related Posts:
- Filter to remove image dimension attributes?
- Change WordPress image URLs via filter
- Always use for post images
- Change html structure of all img tags in WordPress
- Default Image Link Removal
- Remove title attribute from images
- hook into completed image upload filter
- Need help building a filter to edit the output of “image_send_to_editor”
- Filter Media Library by author or post_parent
- Preview Image Path in Admin Section
- How to display a shortcode caption somewhere other than the_content
- Alter image output in content
- How can I remove the image attachment ALT field?
- add data-attribute to all images inside the_content()
- Filter to modify post_title after image upload?
- Change html structure of all img tags in WordPress
- Disable wordpress image sizes generation
- Extend core block attributes in post content
- What’s the proper way to use the get_image_tag filter?
- Can I the caption shortcode to set caption to a data attribute, and with the image’s alignment intact?
- How to get image ID to use inside wp_read_image_metadata()?
- Is there any action/filter hook to use when an image gets edited in the editor?
- How to create ‘Local’ filters for WordPress srcset sizes in template parts?
- How to add custom classes to figure element only if image has caption?
- Change align classes for images
- How to filter the image embed code based on link type
- Add custom text in the media library image meta area
- WP 5.3 Removing Default WordPress Image Sizes
- Filter for post_thumbnail: link to small src and add data-attribute [duplicate]
- Remove Image Sizes in Media Settings Page
- How can I use wp_save_image_editor_file filter?
- How to stop WordPress from completely overriding my tags in my templates?
- Is it possible to enable the ‘Link To’ field under ‘Attachment Display Settings’ for a Featured Image?
- Prevent WP from wrapping html in caption shortcode after ‘image_send_editor’ filter is applied
- How can I change the to for lazyload wp smilies
- How to display a warning when an uploaded image is too small?
- How to change an image source when rendering on frontend?
- How to change Gallery image url in product page ? In function.php?
- How to get title of images in post content
- How to generate alt attributes with php / filters?
- How to trigger “wp_handle_upload_prefilter” filter when uploading an image programatically?
- js alert in add_filter function for image_send_to_editor
- Dinamically modifying attributes of images on posts
- How to attach post ID to image links in WordPress tinymce editor
- image_send_to_editor filter – Unwanted paragraphs and line breaks
- How might one programmatically set the link for all images in all posts?
- Image filter works on attachement pages but not posts. I can’t get the image ID
- Surround uploaded image link with div
- Removing image dimensions from `the_content`
- Rename uploads filenames to POST-ID on upload
- I tried to move the featured image below the paragraphs but now it is displaying twice
- How to add a link to media file for every image inserted in content?
- Replace image with its alt text?
- Get field added via attachment_fields_to_edit filter in Gutenberg
- Neither intermediate_image_sizes_advanced or intermediate_image_sizes filter is firing
- ‘Add Media’ to post – filter images
- Set default image sizes in WordPress to hard crop
- Which action hook can I use when a featured image has been selected
- Image resize with image url
- The WordPress Gallery, Grabbing The Link and Images?
- How to upload images from my directory into my wordpress?
- Add a featured image in my theme?
- help getting featured image using get_posts
- Why can I not view image attachment pages?
- Images are randomly deleted from server
- Restrict Image Uploads to a Certain File Type
- Image popup in a lightbox / overlay from the backend 3.5 admin area (plugin)
- Auto resize images after adding a new size
- media sideload image and Google Content
- Big Image on Featured Post, Normal on Single Post
- Making images in posts link to the image file rather than the attachment page
- offload media to external services [closed]
- Transfer only original images to new site
- Retain the original name of the image on resize
- Creating a post image to show in a gallery
- I want to Add My Product Image to Admin Order Email in Woocommerece [closed]
- image_resize() with blank space [closed]
- Re-ordering images in existing post in wordpress 3.6.1
- Change Image folder Locations
- image_downsize returning an Array?
- Why is WordPress automatically modifying image URLs? (Tracking pixel from RSS)
- Add images to my theme with html
- How to disable a WP Image Block to link to itself?
- Images going blank after a while
- Confused about image sizes generated by WordPress
- Allow users to upload and display multiple photos
- WordPress on IIS works except for image upload widget: Win 10 Pro
- How to show a full page when someone links directly to an image on my site
- The image keep redirect to my previous URL after I moving my site
- Can i use my Old Post image URL in my new post?
- Responsive Featured Images Not Working
- How can we achieve this image css style?
- WordPress 404 Images – Images not found after deleted from media
- How to delete images from database with product
- Bypass wp_safe_remote_get()?
- Specify which image sizes are created on a per image basis
- Extract url from next_image_link
- Title image is missing ( but is not the WP 3.5 issue )
- Why images are disappearing on WordPress web site?
- How to include featured image on blog post preview?