Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author David Aguilera

    (@davilera)

    Hi!

    Unfortunately, our plugin doesn’t have a setting right now for returning a default image. In the meantime, you can hook into a WordPress filter named get_post_metadata:

    function nelioefi_default_image( $metadata, $object_id, $meta_key ) {
    
      if ( '_nelioefi_url' === $meta_key ) {
        $metadata = 'https://example.com/path/to/default-image.jpg';
      }//end if
    
      return $metadata;
    
    }//end nelioefi_default_image
    add_filter( 'get_post_metadata', 'nelioefi_default_image', 10, 3 );

    Please, let me know if this solved your issue!

    Thread Starter wasanajones

    (@wasanajones)

    thanks for the detailed reply

    Plugin Author David Aguilera

    (@davilera)

    You’re welcome! Just let me know how’s it working. If it does work, I’ll close the thread ??

    dont work

    Plugin Author David Aguilera

    (@davilera)

    Hi!

    Why doesn’t this work? By looking at the solution I shared, maybe the following fragment was missing:

    function nelioefi_default_image( $metadata, $object_id, $meta_key ) {
    
      if ( '_nelioefi_url' === $meta_key && empty( $metadata ) ) {
        $metadata = 'https://example.com/path/to/default-image.jpg';
      }//end if
    
      return $metadata;
    
    }//end nelioefi_default_image
    add_filter( 'get_post_metadata', 'nelioefi_default_image', 10, 3 );

    That is, we only set a default image if the current post doesn’t already have one.

    Anyway, I need more information than just “dont work” to help you ??

    Best regards,
    David

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Any way to set default image URL?’ is closed to new replies.