• Resolved omma46

    (@omma46)


    I use base64 coded images, with defer onscroll. I get error when checking the markup, because data src isn’t recognised.

    I load a small base64 image, then load and replace it with the large image when user scrolls the page. This to reduce the size of first view. I would like to use the large image for image markup.

    It could be useful to have a custom field for image markup, similar to heading and description.

    Any other way to solve this?

    thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Hesham Zebida

    (@hishaman)

    There is a filter you can use to override the markup output, I would use that to solve this issue, here is an example of code that you can customize to grab the image from a post meta field:

    function schema_wp_set_default_image_12345( $json ) {
    	
    	// If image is already defiend,
    	// return our $json array and do not do anything
    	if ( isset($json['media']) && ! empty($json['media']) ) return $json;
    	
    	// There is no image defined in Schema array, 
    	// set default ImageObject url, width, and height
    	$json['media']['@type'] = 'ImageObject'; // schema type, do not chage this!
    	$json['media']['url'] = 'http://default-image-url.png'; // set default image url
    	$json['media']['width'] = 720; // set image width
    	$json['media']['height'] = 400;	// set image height
    	
    	return $json;
    }
    add_filter('schema_json', 'schema_wp_set_default_image_12345');

    Here is a link to the code gist.

    I hope this helps.

    Thread Starter omma46

    (@omma46)

    Thanks for the reply.

    This solves the immidiate problem, however it will use the same image for all pages/posts. If there was a custom field for markup, similar to heading and description, i could choose a unique image for every page/post.

    Hi @omma46.

    I’d like to be able to selectively override the image for pages/posts.
    Did you ever manage to add a custom field for images?

    Thanks

    Tim

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Custom field for image url’ is closed to new replies.