Should I not compress my jpeg files before uploading to avoid double compression?

If you want to showcase high-quality images on your website, then you can turn off image compression in WordPress. You can do that by adding this part of code in your functions.php : add_filter(‘jpeg_quality’, function($arg){return 100;}); Or you can create your plugin : <?php /** * Plugin Name: Remove WordPress Image Compression * Plugin URI: … Read more

Call to undefined function wp_generate_attachment_metadata()

Despite you already solved it (the “undefined” issue), it should be noted that wp_generate_attachment_metadata() is defined in wp-admin/includes/image.php, so you need to manually load that file if you’re using the function on the front-end, i.e. public side of the site or non admin/wp-admin pages (e.g. single attachment pages). And in fact, the function reference says … Read more

Upload media only to DB

Yes, out of the box WordPress stores images and other uploads only as files. Although it could be, theoretically, possible to change this behavior by tapping inton wp_handle_upload() or _wp_handle_upload() and related functions, I think it would be too complex and unreliable. Besides,I think it wouldn’t be a good idea for performance reasons in case … Read more

Bulk Upload Image Alt Text

TRY THIS,IT MAY HELPFUL Converted to CSV file. uploaded to root folder having column structure as given which contains attachment image ID and alter text run this code for one time only $row = 1; if( ($handle = fopen ( “Book1.csv”, “r” )) !== FALSE ) { while ( ($data = fgetcsv ( $handle, 1000, … Read more

How to get the Gallery form/section just like in Gutenberg block?

wp.media is the JavaScript API WordPress uses to display the media library modal. You can use it yourself by enqueueing a custom JS script on your admin page: wp_enqueue_script(‘media-upload’); wp_enqueue_media(); wp_enqueue_script( ‘pb-admin-script’, ‘admin.js’, array( ‘jquery’, ) ); Then work with it like this: HTML: <button class=”upload_image_button button button-primary”> <?php _e(‘Upload Image’, ‘pb’); ?> </button> <img … Read more

In creating a theme, how can i allow a user to change an image outside post/page content?

I ran into a similar problem recently. I found plug-in called “image widget” http://wordpress.org/extend/plugins/image-widget/screenshots/ that enabled upload right in the widget. The client though had no idea how to barely log in and find the widgets so I ended up using a flickr widget since it was more user friendly ( aka they could upload … Read more