private WPEditImageSpan createWPEditImageSpanLocal(Context context, MediaFile mediaFile) {
   Uri imageUri = Uri.parse(mediaFile.getFilePath());
   Bitmap thumbnailBitmap;
   if (MediaUtils.isVideo(imageUri.toString())) {
     thumbnailBitmap =
         BitmapFactory.decodeResource(context.getResources(), R.drawable.media_movieclip);
   } else {
     thumbnailBitmap =
         ImageUtils.getWPImageSpanThumbnailFromFilePath(
             context,
             imageUri.getEncodedPath(),
             ImageUtils.getMaximumThumbnailWidthForEditor(context));
     if (thumbnailBitmap == null) {
       // Use a placeholder in case thumbnail can't be decoded (OOM for instance)
       thumbnailBitmap =
           BitmapFactory.decodeResource(
               context.getResources(), R.drawable.legacy_dashicon_format_image_big_grey);
     }
   }
   WPEditImageSpan imageSpan = new WPEditImageSpan(context, thumbnailBitmap, imageUri);
   mediaFile.setWidth(
       MediaUtils.getMinimumImageWidth(context, imageUri, mBlogSettingMaxImageWidth));
   return imageSpan;
 }
  private void loadWPImageSpanThumbnail(
      MediaFile mediaFile, String imageURL, ImageLoader imageLoader) {
    if (mediaFile == null || imageURL == null) {
      return;
    }
    final String mediaId = mediaFile.getMediaId();
    if (mediaId == null) {
      return;
    }

    final int maxThumbWidth = ImageUtils.getMaximumThumbnailWidthForEditor(getActivity());

    imageLoader.get(
        imageURL,
        new ImageLoader.ImageListener() {
          @Override
          public void onErrorResponse(VolleyError arg0) {}

          @Override
          public void onResponse(ImageLoader.ImageContainer container, boolean arg1) {
            Bitmap downloadedBitmap = container.getBitmap();
            if (downloadedBitmap == null) {
              // no bitmap downloaded from the server.
              return;
            }

            if (downloadedBitmap.getWidth() < MIN_THUMBNAIL_WIDTH) {
              // Picture is too small. Show the placeholder in this case.
              return;
            }

            Bitmap resizedBitmap;
            // resize the downloaded bitmap
            resizedBitmap =
                ImageUtils.getScaledBitmapAtLongestSide(downloadedBitmap, maxThumbWidth);

            if (resizedBitmap == null) {
              return;
            }

            final EditText editText = mContentEditText;
            Editable s = editText.getText();
            if (s == null) {
              return;
            }
            WPImageSpan[] spans = s.getSpans(0, s.length(), WPImageSpan.class);
            if (spans.length != 0 && getActivity() != null) {
              for (WPImageSpan is : spans) {
                MediaFile mediaFile = is.getMediaFile();
                if (mediaFile == null) {
                  continue;
                }
                if (mediaId.equals(mediaFile.getMediaId()) && !is.isNetworkImageLoaded()) {
                  // replace the existing span with a new one with the correct image, re-add
                  // it to the same position.
                  int spanStart = is.getStartPosition();
                  int spanEnd = is.getEndPosition();
                  WPEditImageSpan imageSpan =
                      new WPEditImageSpan(getActivity(), resizedBitmap, is.getImageSource());
                  imageSpan.setMediaFile(is.getMediaFile());
                  imageSpan.setNetworkImageLoaded(true);
                  imageSpan.setPosition(spanStart, spanEnd);
                  s.removeSpan(is);
                  s.setSpan(imageSpan, spanStart, spanEnd + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                  break;
                }
              }
            }
          }
        },
        0,
        0);
  }