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;
 }
    /** Finds media in post content, uploads them, and returns the HTML to insert in the post */
    private String processPostMedia(String postContent) {
      String imageTagsPattern = "<img[^>]+android-uri\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>";
      Pattern pattern = Pattern.compile(imageTagsPattern);
      Matcher matcher = pattern.matcher(postContent);

      int totalMediaItems = 0;
      List<String> imageTags = new ArrayList<String>();
      while (matcher.find()) {
        imageTags.add(matcher.group());
        totalMediaItems++;
      }

      mPostUploadNotifier.setTotalMediaItems(totalMediaItems);

      int mediaItemCount = 0;
      for (String tag : imageTags) {
        Pattern p = Pattern.compile("android-uri=\"([^\"]+)\"");
        Matcher m = p.matcher(tag);
        if (m.find()) {
          String imageUri = m.group(1);
          if (!imageUri.equals("")) {
            MediaFile mediaFile = WordPress.wpDB.getMediaFile(imageUri, mPost);
            if (mediaFile != null) {
              // Get image thumbnail for notification icon
              Bitmap imageIcon =
                  ImageUtils.getWPImageSpanThumbnailFromFilePath(
                      mContext, imageUri, DisplayUtils.dpToPx(mContext, 128));

              // Crop the thumbnail to be squared in the center
              if (imageIcon != null) {
                int squaredSize = DisplayUtils.dpToPx(mContext, 64);
                imageIcon = ThumbnailUtils.extractThumbnail(imageIcon, squaredSize, squaredSize);
                mLatestIcon = imageIcon;
              }

              mediaItemCount++;
              mPostUploadNotifier.setCurrentMediaItem(mediaItemCount);
              mPostUploadNotifier.updateNotificationIcon(imageIcon);

              String mediaUploadOutput;
              if (mediaFile.isVideo()) {
                mHasVideo = true;
                mediaUploadOutput = uploadVideo(mediaFile);
              } else {
                mHasImage = true;
                mediaUploadOutput = uploadImage(mediaFile);
              }

              if (mediaUploadOutput != null) {
                postContent = postContent.replace(tag, mediaUploadOutput);
              } else {
                postContent = postContent.replace(tag, "");
                mIsMediaError = true;
              }
            }
          }
        }
      }

      return postContent;
    }