2
  • I'm trying to load a thumbnail for an article on the web using Glide, but it returns an empty field.
  • Unlike other examples this URL does not directly link to a PNG/JPG etc, rather its a website link from which I require it to load the default thumbnail.
  • The ImageView has been set & initialised properly.
  • I have used Glide & Picasso in separate attempts, but it the ImageView is blank.

Snippet

ivGlide = (ImageView) findViewById(R.id.ivGlide);

String uriLoad = "http://www.recode.net/2016/7/26/12281110/facebook-video-360-degree-camera";

//USING GLIDE
Glide.with(Activity_glidetest.this)
.load(uriLoad) 
.centerCrop()
.into(ivGlide);

    //USING PICASSO
    Picasso.with(Activity_frienddetail.this)
    .load(uriLoad)
    .resize(78, 78)
    .centerCrop()
    .into(ivGlide);

XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ImageView
        android:id="@+id/ivGlide"
        android:layout_width="78dp"
        android:layout_height="78dp"
        android:src="@drawable/hand"
        android:layout_centerInParent="true" />

</RelativeLayout>
Zen
  • 2,698
  • 4
  • 28
  • 41
  • Did you give in manifest ? – Nisarg Jul 27 '16 at 12:26
  • The url is not an image url, you should pass to Glide/Picasso an image url – Chol Jul 27 '16 at 12:43
  • In your example it should be : https://cdn1.vox-cdn.com/thumbor/0LIdoMHrI6QiVjaB00iZCQY17lQ=/800x533/filters:focal(2592x1241:3444x2093):no_upscale()/cdn1.vox-cdn.com/uploads/chorus_image/image/50207157/Surround360_1.0.jpg – Chol Jul 27 '16 at 12:44
  • @Chol How do I retrieve the image url from the website link? – Zen Jul 27 '16 at 12:45
  • Don't know... In the source code page you can find it here – Chol Jul 27 '16 at 12:46
  • I think you'll need something to get the html page form the url and then search for the og:image property – Chol Jul 27 '16 at 12:47
  • Is there any code for Android that you can share does this? @Chol – Zen Jul 27 '16 at 12:48
  • I really don't know, I have never tried, need to find by yourself – Chol Jul 27 '16 at 12:49
  • Check this: http://stackoverflow.com/questions/6503574/how-to-get-html-source-code-from-url-in-android – Chol Jul 27 '16 at 12:49

1 Answers1

0

You need to provide Glide/Picasso a direct link to article image. Try to find this site API, or use some "any website to API" tools, I believe it'll give you article image.

Ekalips
  • 1,473
  • 11
  • 20