logo
down
shadow

Create oembed previews for my selfhosted WP?


Create oembed previews for my selfhosted WP?

By : f z
Date : November 17 2020, 01:00 AM
To fix the issue you can do A self-hosted oEmbed provider: A simple Hello World demo
Here's a very simple demo of a self hosted oembed provider (site A) that implements the json spec on oembed.com for rich type responses. Other available types are link, photo and video.
code :
/**
 * Demo: A simple self-hosted oEmbed provider.
 */

add_action( 'template_redirect', 'simple_oembed_provider_so27693829' ) 

function simple_oembed_provider_so27693829()
{
    // Catch the user input:
    $input = filter_input_array( INPUT_GET, array(
        'simple-oembed'   => FILTER_SANITIZE_NUMBER_INT,
         'url'       => FILTER_SANITIZE_URL,
         'format'    => FILTER_SANITIZE_STRING,
         'maxwidth'  => FILTER_SANITIZE_NUMBER_INT,
         'maxheight' => FILTER_SANITIZE_NUMBER_INT,
        )
    );

    // Our oembed service is activated:
    if( 1 == $input['simple-oembed'] )
    {
        //--------------
        // We only support json format:
        //--------------
        if( 'json' != $input['format'] ) 
        {
            status_header( 501 ); 
            nocache_headers();
            exit();

        $pid = url_to_postid( $input['url'] );

        //--------------
        // The url doesn't exists:
        //--------------
        if( 0 == $pid ) 
        {
            status_header( 404 );     
            nocache_headers();
            exit();
        }

        //--------------
        // json output:
        //--------------
        else
        {
            $post = get_post( $pid );
            $data = array(
                'version' => '1.0',
                'type'    => 'rich',
                'width'   => empty( $input['maxwidth'] ) ? 600 : min( 600, $input['maxwidth'] ),
                'height'  => empty( $input['maxheight'] ) ? 400 : min( 400, $input['maxheight'] ), 
                'html'    => sprintf(
                   '<div class="simple-oembed"><h2><a href="%s">%s</a></h2><p>%s</p></div>',
                    get_permalink( $pid ),
                    apply_filters( 'the_title', $post->post_title ),    
                    'Check out this great post!'
                )
            );
            wp_send_json( $data );
        }
    }
}
add_action( 'init', 'add_our_oembed_provider_so27693829' );

function add_our_oembed_provider_so27693829()
{
    wp_oembed_add_provider( 
        $format   = 'http://site-a.tld/*', 
        $provider = 'http://site-a.tld/?simple-oembed=1&' 
    );
}
http://site-a.tld/?simple-oembed=1
&format=json
&maxwidth=625
&maxheight=938
&url=http://site-a.tld/hello-world/
{
    "version":"1.0",
    "type":"rich",
    "width":600,
    "height":400,
    "html":"<div class=\"simple-oembed\"><h2><a href=\"http:\/\/site-a.tld\/hello-world\/\">Hello World from Site A<\/a><\/h2><p>Check out this great post!<\/p><\/div>"
}


Share : facebook icon twitter icon
Create mp3 previews from wav and aiff files

Create mp3 previews from wav and aiff files


By : user1882730
Date : March 29 2020, 07:55 AM
hope this fix your issue I wanted to use something as low level as possible, so I ended up using RubyAudio, a wrapper for libsndfile.
code :
require "rubygems"
require "ruby-audio"

EXTRACT_BEGIN = 11.2
EXTRACT_LENGTH = 3.5

RubyAudio::Sound.open("/home/augustl/sandbox/test.aif") do |snd|
  info = snd.info
  ["channels", "format", "frames", "samplerate", "sections", "seekable"].each do |key|
    puts "#{key}: #{info.send(key)}"
  end

  # TODO: should we use a 1000 byte buffer? Does it matter? See RubyAudio::Sound rdocs.
  bytes_to_read = (info.samplerate * EXTRACT_LENGTH).to_i
  buffer = RubyAudio::Buffer.new("float", bytes_to_read, info.channels)

  snd.seek(info.samplerate * EXTRACT_BEGIN)
  snd.read(buffer, bytes_to_read)

  out = RubyAudio::Sound.open("/home/augustl/sandbox/out.aif", "w", info.clone)
  out.write(buffer)
end
How can I create 'tab previews' in a Metro app?

How can I create 'tab previews' in a Metro app?


By : Moe Garcia
Date : March 29 2020, 07:55 AM
this will help No, it's not a standard control.
If you're looking to capture the image as is done with IE, in Windows 8.1 store applications, when using the WebView, you can use the method capturePreviewToBlobAsync function to grab an image of the currently displayed content in the WebView.
How to create a Certificate Signing Request (CSR) OWIN Selfhosted

How to create a Certificate Signing Request (CSR) OWIN Selfhosted


By : user3782971
Date : March 29 2020, 07:55 AM
hop of those help? To generate a CSR on Windows without IIS you can use OpenSSL, download it for windows from www.openssl.org
Run the following openssl command (via run or cmd.exe)
code :
openssl.exe req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout private.key
Rails mailer previews not available from spec/mailers/previews

Rails mailer previews not available from spec/mailers/previews


By : Matthias Tschaffler
Date : March 29 2020, 07:55 AM
This might help you I would like to be able to preview my emails in the browser. , Use
code :
config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews"
Is there way to create a true selfhosted .Net ( Core) wepApp without any proxy

Is there way to create a true selfhosted .Net ( Core) wepApp without any proxy


By : Matthew Richen
Date : March 29 2020, 07:55 AM
this one helps. I guess you mean that your self-hosted web server of visual studio is not accessible from the outside?
Assuming that your port forwarding and firewall are correctly configured. You need to change the bind address of your application:
code :
new WebHostBuilder()
    .UseKestrel()
    ...
    .UseUrls("http://*:80")
    ...;
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org