New answers tagged

0

As per outlined in the comments, by fixing a typo in my save function, and setting the third parameter in get_post_meta() to true, and false in selected() it worked liked a charm. Thanks everyone! Here's the working code in case anyone is trying to add a select list custom field to their media manager: /* Add license field to media attachments */ ...


3

Attachments in WP are stored as posts of type attachment which reference files physically stored in the uploads folder. This is why if you FTP a file into the uploads folder it doesn't appear in the media library. This means the media library is a post archive, much like other post archives in the admin and frontend. Specifically listing posts of type ...


1

There's wp_get_attachment_image_url introduced in WordPress 4.4.0. It takes these arguments: int $attachment_id - Image attachment ID. string|array $size - Optional. Image size to retrieve. Accepts any valid image size, or an array of width and height values in pixels (in that order). Default 'thumbnail'. bool $icon - Optional. Whether the image should be ...


0

thanks for your help. I used this variant of your code with a little diffrent preg_replace code. If the Image URL contain numbers like "-510x383.jpg" i had some Problems with your code. <?php if( is_single() ) { global $post; $pattern = '/<img.*src="([^"]+)"[^>]*>/'; $matches = []; preg_match_all( $pattern,...


0

The cause was WPML settings which dupplicates media. :/


0

If you want to get the actual images inside the post content, you can match them using a regular expression. To get just the images URLs and dimensions your code can be something like this: if( is_single() ) { global $post; // Match the image URLs inside the post content $pattern = '/<img.*src="([^"]+)"[^>]*>/'; $...


0

I can't find the define of the ajaxurl variable. The 404 is inevitable. Usually, you need to define it in your function or directly in a wp_localize_script action. Dont't forget to replace the wp_ajax_pn_reg_vendors, to make it work, even the user is not yet connect.


Top 50 recent answers are included