How to generate thumbnail images of HTML pages - javascript

I am trying to create thumbnail images for several HTML pages, so the user can have an idea of what the HTML looks like before they open the link. I have searched online but haven't found anything useful.
Could anyone here provide some tips? Thanks so much!
I specifically want this to happen on the server side so the client is not required to load the page

You might want to check out this url: http://html2canvas.hertzen.com/.
Using this script, you can convert the page into a canvas on the client side.
Then you can use that as your thumbnail.

You have to use Open Graph tags in you header tag:
<html>
<head>
<meta property="og:site_name" content="Your Website Name Here" />
<meta
property="og:title"
content="Yourtitle goes here, about 90 characters in length."
/>
<meta
property="og:description"
content="description of URL that is about 300 characters in length."
/>
<meta property="og:image" content="YOURIMAGEURL.JPG" />
<meta property="og:type" content="blog" />
<meta property="og:url" content="http://yourURL.com/" />
</head>
<body></body>
</html>

http://api.s-shot.ru/?=(your url)
and
https://s.wordpress.com/mshots/v1/(your url)
I hope those Help!

http://phantomJs.org offers a free tool to capture HTML locally from a file (if you enable that via a command line parameter and use the file:// URI scheme) or from a website and render it to an image. That is a very well-established very popular tool It's also used by people who write automated tests. There's a wiki page that covers that tool, and similar ones.
It has a cropping option. You could run the output of that through other image manipulation tools to scale it.
As far as getting intelligent previews/thumbnails like Twitter and Facebook do, that I'm not sure of. I know there is an oEmbed protocol that is popular that Twitter and other sites provide, and ways to extract the metadata whereby you could possibly construct your own small HTML file and then render it to an image.
(Note about phantomJs: If you don't get the image quality you want in the rendered image, try raising the quality setting for the image parameter to 100, as well as increasing the page's zoom factor option. I've found zoom factor of 2 produces profoundly better quality than zoom factor 1 - see the API docs regarding zoom).

I couldn't get phantomjs to work for my site for some reason, and in further searching I stumbled on this technique for using an iframe to simulate a thumbnail. Posting this here in case others find it useful.

Related

How to get a true video url for exoplayer from google drive shared video link?

I want to play video from google drive in exoplayer. I copied the shareable link. But this link leads to google drive video player page. I have checked shareable link response, it contains link for video thumb image and also the video link. But this video link is calling any code further to play the video. I want to get or more specifically extract the true video playable link from the response. Here is the code portion from the response which contains important links,
<meta name="referrer" content="origin">
<title>KOB-S3-E1.mp4 - Google Drive</title>
<meta property="og:title" content="KOB-S3-E1.mp4">
<meta property="og:type" content="video.other">
<meta property="og:site_name" content="Google Drive">
<meta property="og:url" content="https://drive.google.com/file/d/1eqNQOwDzDDjHizpUz-sB86VK4LisqGu1/view?usp=sharing&usp=embed_facebook">
<meta property="og:image" content="https://lh4.googleusercontent.com/eqNekxifrzidbBB-SzJbdJJ1xcOY6NFgR_0wIXHAnX-uHLO3FfUmgt-AokDallwbAXI=w1200-h630-p">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:video" content="https://video.google.com/get_player?docid=1eqNQOwDzDDjHizpUz-sB86VK4LisqGu1&ps=docs&partnerid=30&cc_load_policy=1">
<meta property="og:video:type" content="application/x-shockwave-flash">
The image thumb link is working, but the I can't find the link which I can use to play video in exo player android app.
This is the original shareable link:
https://drive.google.com/file/d/1eqNQOwDzDDjHizpUz-sB86VK4LisqGu1/view?usp=sharing
Google Drive video's are not designed to be streamed directly as you want - it can be done, see below, but you need to be aware that, as this is not the intended use, you could find it stops working overnight if Google Drive update the way they have architected or deployed their solution.
With the above caveat in mind, there are approaches that will allow you extract the original video URL - see this answer for a good example which outlines a number of approaches: https://stackoverflow.com/a/52397246/334402
One thing to be aware of - your original hosted video is actually being delivered using ABR streaming protocols, which means the video is copied into different resolutions/bitrates on the server side and each copy broken into chunks. The player can decide which resolution to download for the next chunk based on the current network conditions and player capabilities. See, for example, the 'quality' options for your video by looking at the settings:
Depending on the approach you use you may need to be aware of the particular URL for the specific resolution you want.
If you simply want to play the video back in an app and it does not need to be via ExoPlayer you may find it much easier to simply use the standard embed code within a Webview in your app.

Dynamic Twitter Card Images

I have a Twitter share button on an application I'm building. I am using the Twitter card <meta> tags (documentation) to define the image that shows up on Twitter. The application is dynamic and allows you to share individual 'reports'. When you share an individual report, I have a query parameter ?report=1608 (see example).
The problem: I can only define one Twitter card for the entire site. I would love to dynamically change the card information (title, text, image) for each individual report that is shared.
Can this be done? Any ideas?
I was thinking about just updating the meta tags dynamically with JavaScript, but I don't think this would work as a solution.
No, this is not possible. Twitter's card crawler (Twitterbot) does not support executing Javascript in the page and requires that the meta tags are static. There's no way to do this dynamically.
It is possible, you can dynamically load in the title, text and the image. I tried it and it worked... but it takes a little time to populate on the browser/website, but it works perfectly/instantly on the twitter app... need a workaround for that... Let me know if you find any solution for that. This is how I used it:
<?php
if (isset($_GET['code'])) {
?>
<meta name="twitter:card" content="summary_large_image">
<meta property="og:image" content="https://example.domain/i/<?= $_GET['code'] ?>.png" />
<meta name="twitter:image" content="https://example.domain/i/<?= $_GET['code'] ?>.png">
<meta name="twitter:image:alt" content="image_alt">
<?php
}
?>
I think you can do the SSR. good luck

share on facebook with query string

I have the following problem I can't find a proper solution for and would be very graceful for any advice.
On my website, I provide a sharing option for facebook:
Jetzt teilen
I use open graph to add meta information for the FB crawler
<meta property="og:url" content="http://www.mypage.de" />
<meta property="og:type" content="website" />
<meta property='og:title' content='MyPage'>
<meta property='og:description' content='Viele tolle Sachen'>
<meta property='og:image' content='http://www.mypage.de/image.jpg'>
This works fine so far. The user will see Image, description and Titel.
But as I want to add individual information on each shared link, I need to add a query string that is shared ( ?queryString=qwe123 ). So I change the URL:
Jetzt teilen
But when the user now clicks the link, he wont see the description and image of the page any more (the linking works fine anyway). I cant let FB crawl every possible query-string because each user has an individual one.
Anyone has a good idea?
P.S. I know that share.php is deprecated, but don't know whats the actual way to share without using an App_ID from FB.
P.P.S. I use angular 1.4 if that is of any importance

Set the Thumbnail Image for Facebook Share Buttons 2016?

I'm attempting to set a custom thumbnail for when people share my website on Facebook. I followed this post here: How does Facebook Sharer select Images and other metadata when sharing my URL?
It seems this info may be outdated because I am unable to get it to work. Can anyone advise if there has been a change and how to handle this now?
I currently have this in my head but It is not working:
<head>
<meta property="og:image" content="http://placehold.it/350x150"/>
<meta property="og:image:secure_url" content="https://placehold.it/350x150" />
</head>
Figured it out. Facebook simply had not refreshed my images yet. I found this tool to help with this process:
https://developers.facebook.com/tools/debug/

how to include small image with google share button

<li></li>
How could I add a message and a small image to share with the above (URL that currently does).
There are a couple of ways to accomplish what you're trying to do.
Option 1: Microdata
This would be the best way in my opinion, but it may take a bit of getting used to. Microdata is very powerful and there are many implementations for different types of data. The standard can be found on schema.org.
Google has a nice tool for testing Microdata, it's called the Structured Data Testing Tool.
Option 2: Open Graph Protocol
This is a bit easier to implement as it's simply just adding meta tags that are named following the protocol listed on their website.
Example:
<meta property="og:title" content="Your title about post" />
<meta property="og:url" content="http://www.website.com/coolwebsite/" />
<meta property="og:image" content="http://www.website.com/images/g_co.jpg" />

Categories

Resources