How to add a media with PHP

If I’m understanding correctly, each post has a filemaker, and each filemaker has only one photo? The structure is kind of unclear. Anyways, one way is top use media_sideload_image like below. However, media_sideload_image WON’T work with local files (a path on your filesystem), so you need to change your $file[‘url’] to be a valid URL … Read more

Disable edit option in Media library

There’re several filters that you can utilize: Custom column content If you got a custom column that you added with the “-filter, then you can use the manage_{$post->post_type}_posts_custom_column filter to alter the content. If you only want to target non-hierarchial post types then there’s as well the manage_posts_custom_column and for hierarchical ones, there’s manage_pages_custom_column. All … Read more

FTP files directly to Media Library wp-content\uploads

I would suggest using WP CLI for that. It’s the (in)official WordPress command line tool, like Drush for Drupal or the Symfony2 Console Component. Use the media command to handle your (future) attachments: wp media import <file> [–option=value*] * Take a look at the docs or the CLI help tool to see what options you … Read more

Which hook is fired when inserting media into a post

The add_attachment action is fired when the wp_insert_attachment() function is called to add an item to the media library. Images are added to posts after going into the media library first. Even when adding via the post editor, items are added to the library with wp_insert_attachment() then to the post. add_action( ‘add_attachment’, function( $post_ID ) … Read more

Upload images from custom plugin using the media modal

Ah! The classic issue anyone that’s cared about their users’ experience has come to face. As per my experience, wp.media is the way to go. This is not my code, but it gets the job done. I’ve used it plenty. I’ll explain what it does, piece by piece: // Source: https://vedmant.com/using-wordpress-media-library-in-widgets-options/ jQuery(document).ready(function ($) { $(document).on(“click”, … Read more

WordPress media upload “HTTP error”

I figured out how to fix my problem. In my nginx config file (/etc/nginx/nginx.conf) I added client_max_body_size 100m; at the end of the #Basic Settings in the http {} section. I hope this answer will help some of you and please tell me if there is any better solution to this problem.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)