How to Add extra option to Image Block Settings?

This can be done using block filters. First, you’ll need to filter block attributes for the image block to be able to save the new items: const { addFilter } = wp.hooks; function filterAttributes( settings, name ) { if ( ‘core/image’ === name && settings.attributes ) { settings.attributes.description = { type: ‘string’, default: ” }; … Read more

How to install Imagick or resolve issue

It seems as though you dont have the required permissions to install this PHP extension. This is often the case when youre using shared hosting. The best option is to contact your hosting provider and ask them to install this php extension. However if they provide you with a cpanel dashboard you may be able … Read more

There’s some way to add a wrapper around posted images?

The image_send_to_editor hook passes a whole range of parameters, not just the html. One of them is the size. To get it, hook your filter passing an 8 as the number of supported parameters: add_filter(‘image_send_to_editor’, ‘my_filter_cb’), 10, 8); and modify your function header to grab them all: function my_filter_cb ($html, $id, $caption, $title, $align, $url, … Read more

Front-end Image Upload with Preview – Is this Possible in WP?

Just add this scripts in header <script src=”http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js”></script> <script> var blank=”http://upload.wikimedia.org/wikipedia/commons/c/c0/Blank.gif”; function readURL(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { $(‘#img_prev’) .attr(‘src’, e.target.result) .height(100); }; reader.readAsDataURL(input.files[0]); } else { var img = input.value; $(‘#img_prev’).attr(‘src’,img).height(200); } $(“#x”).show().css(“margin-right”,”10px”); } $(document).ready(function() { $(“#x”).click(function() { $(“#img_prev”).attr(“src”,blank); $(“#x”).hide(); }); }); </script> … Read more

Get uploaded image url

wp_upload_dir() is perfect. It is the only place where you can expect write permissions. Store the attachment ID, not a path. Then you get the image with: wp_get_attachment_url( $attach_id ) Sometimes a user may have deleted the image per media library. To avoid problems with missing files check the return value from wp_get_attachment_url() first. Excerpt … Read more