You don’t need to use strpos()
to figure out the extension because you’ve already parsed the URL above and stored the extension in $AllAtachmentURLextension
, so all you need to do is
//for Specific Extensions
if( 'docx' == $AllAttachmentURLextension ) {
// docx handling here
}
elseif ( 'pdf' == $AllAttachmentURLextension ) {
// pdf handling here
}
Related Posts:
- Where do the favicons for Media Files come from
- How to get all files inserted (but not attached) to a post
- Password protect some uploaded files, so only logged-in users can view them
- Images not being generated at correct size
- Use the WP media uploader dialog for uploading a form attachment (non-admin). Offering progress and drag and drop feedback
- What is the way to add additional fields to attachments in 3.5+?
- A link (not in the post) to download a specific PDF file
- How does WordPress decides how many sizes of an image to create?
- Insert attachments from custom uploader into post (regular uploader style)
- PDF Upload from Input Error
- Do custom post type (CPT) attachments/media store the parent post ID?
- Adding attachment custom field metadata to TinyMCE tag
- Check if author or uploader id of the attachment(uploaded) image is match?
- Limit attachment caption characters
- controlling whether upload is attached to post or not
- Updating Media Library PDF’s in bulk
- How to properly move media files and update data?
- what happens to existing media files when I switch to year/month directory structure format?
- Can’t upload media, permissions are correct
- Display attachments by ID in a wp.media frame
- Image upload callback in new 3.5 media
- How to wp_upload_bits() to a sub-folder?
- “Add Media” only shows “Full Size” under Attachment Display Settings
- Differentiate Featured Image from Post Images upon Upload
- Uploading Multiple Attachments From Front-End With A Description
- How to manage a standalone media folder?
- Saving images from Gravity Forms repeatable File Upload as post attachments [closed]
- How do I link directly to uploaded files?
- Is it possible to trigger some JavaScript when Media Popup is opened?
- Is wp_read_audio_metadata() function deprecated?
- There’s a way to scale media (images) at 50%?
- Multisite, upload images directly to Amazon S3
- Media Uploader: get deleted files
- WordPress REST Upload Media
- Force wordpress to see uploads folder media
- How to validate the file name of the Media File Uploads?
- Disable TinyMCE Drag and Drop
- Post Specific Uploader
- Setting wp_temp_dir and permissions not working for “Missing A Temporary Folder” error
- Select image sizes you want to be uploaded
- Check if image exists before uploading with media_sideload_image()
- Media upload via backend doen’t work after moving site
- Setting higher upload limit
- Media handle sideload not working
- How do I get allowed Media Library upload file extension list?
- Cannot upload .mp3 file to wordpress media
- Uploading dwg files to wordpress
- How to manage a big collection of files with wordpress?
- Force documents to appear in Featured Image dialogue
- WordPress suddenly starts uploading media to an old (backdated) folder
- Switch between tabs on “Insert Media” dialog
- Is It Possible to Upload Certain Attachment Files To A Remote Server
- Can I change the URL of a video, or upload a video to a specific URL?
- WordPress Issue : The uploaded file could not be moved to wp-content/uploads/
- Using wp_enqueue_media() with switch_to_blog() issue
- making media URL secured
- How to allow logged out users to upload media?
- Is it safe to allow non-admin users access to media uploader
- PHP error when trying to upload .mp3 files via Media Library [closed]
- Get images attached to a specific page
- Is it possible to import all files from a uploads DIR into WP media, retaining paths to the files
- Flat media folder vs multiple directories
- Move media files from the root to date folder structure
- Big file upload give HTTP error
- Can you limit the size of media files being uploaded not using php.ini?
- Image upload to media library fails. Folder won’t create, database insert fail, XAMPP Windows
- Send media uploads to different directories
- Open Media Uploader Link in single post or page
- How to change archieve frequency of the media file in uploads folder for wordpress blog
- How to limit sizes for specific upload programmatically?
- Uploaded images result in a file url with full path on disk appended
- Using WP-CLI “wp media import” to sync files to the media library
- Import media (.xml) does not attribute featured images to posts
- Blog suddenly can’t display .jpg
- MIME type not supporting HEIC support type in WordPress
- SVG not displaying in Media Tab in Backend
- Modify Maximum upload file size text in WordPress Media
- Replicate Media Galley Edit view in Add Media View
- Front-End Upload media with category
- How to manually set an attachment in a post?
- Sanitizing existing media library paths and page links from foreign characters
- Issue with upload.php with media
- Media files not loading
- Set default “Link CSS Class” in add media admin editor
- media_sideload_image results in http error (500)
- How could you allow users to upload a video in within their profile and display it on a wordpress site?
- How to share media between independent blogs?
- media_handle_upload on mix form fields (not required file input)
- WP Capabilities to Add Media, Use Media, But Not Edit Them
- Password protected uploaded PDF page
- Don’t show avatars in media library
- Insert media while posting is not working with new wordpress update
- Media Library broken images
- Importing blog failed to download attachments from older (still online) blog
- Media Gallery doesn’t show (using WP-Read Only)
- How do I update attachment urls after changing site domain
- I am facing problem in loading and downloading Mp3 files
- How to disable direct media file access in nginx or ubuntu for non loggedin users?
- Does WordPress import export tool keeps the file hosted on the old website?
- Cannot add image (png, jpeg, etc.) but can add pdf, 403 forbidden when posting