Uncaught Error: Call to undefined function file_is_valid_image()

I’m running the code above as WP cron The file_is_valid_image function is defined in wp-admin/includes/image.php, and this file is loaded automatically only on WordPress admin pages (in wp-admin). So if you want to use that function on other/non-admin pages, e.g. a page in the site’s front-end, a REST API endpoint, or wp-cron.php which runs during … Read more

problems with alt text not appearing in source code

The display/use of various <img> attributes is up to the theme code. If the theme code does not use the info from the media item, then it will not display. Fixing this will require digging into the theme code to figure out where the <img> code is generated, and then modifying that code. Note that … Read more

WordPress can’t get image url but both the attachment and the actual file are there

Not sure how you’re using it, but wp_get_attachment_image_src() returns an array. This should work: <?php $attachmentID = 519271; $imageSizeName = “thumbnail”; $img = wp_get_attachment_image_src($attachmentID, $imageSizeName); ?> <img src=”<?php echo $img[0]; ?>” alt=”image”> An alternative to try if it isn’t working: <img src=”<?php echo wp_get_attachment_url(519271); ?>” alt=”image”> This thread discusses your issue further: wp_get_attachment_image_src always returns … Read more

Get content from one WordPress website to another

If you have access to the old WordPress site go into the admin section then > Tools > Export. Where it says Choose what to export check All content, and click Download Export file. In the new WordPress site go into the admin section > Tools > Import > choose WordPress form the list (it … Read more

How to show file type of featured image?

If you want to show the File type of featured image. then try the below code. <?php $id1 = get_post_thumbnail_id($post->ID); $type = get_post_mime_type( $id1 ); $mime_type = explode(“https://wordpress.stackexchange.com/”, $type); $type=”.”.$mime_type[‘1’]; echo $type; ?> It will display the exact extension that you want “.jpeg” from “image/jpeg” Here “$post->ID” is current post id (or the id of … Read more

How to get the attribues (alt and title) of an image import with ACF [closed]

It’s already in the docs. Try this: <?php $image = get_field(‘image’); if( !empty($image) ): ?> <img src=”https://wordpress.stackexchange.com/questions/223867/<?php echo $image[“url’]; ?>” alt=”https://wordpress.stackexchange.com/questions/223867/<?php echo $image[“alt’]; ?>” /> <?php endif; ?> For easier debugging, try this: var_dump($image); to print out the $image variable to know what is in $image. You can also put var_dump($image) inside <pre> tag for … Read more