1

First of all, sorry that i don't speak english well.

The following code :

    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == INTENT_REQUEST_GET_N_IMAGES) {
            Parcelable[] parcelableUris = intent.getParcelableArrayExtra(ImagePickerActivity.EXTRA_IMAGE_URIS);

            if(parcelableUris ==null) {
                return;
            }
            Uri[] uris = new Uri[parcelableUris.length];
            System.arraycopy(parcelableUris, 0, uris, 0, parcelableUris.length);
            if(uris != null) {
                int i=0;
                for (Uri uri : uris) {
                    Log.i(TAG, " uri: " + uri);
                    //uri=Uri.parse(Bitmap.Config.getPhotoPath(this));
                    try {
                        Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
                        list.add(new Item(bitmap,"" + i));

                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                myAdapter.notifyDataSetChanged();
            }
            // show images using uris returned.
        }
    }
}

is throwing java.io.FileNotFoundException

So, I tried to apply this solution, but there is no method Config.getPhotoPath

I would appreciate your help.

Community
  • 1
  • 1
HwanIk Kim
  • 11
  • 1

1 Answers1

0

Following code snippet can be useful.

private static function _image(Image $image, $base)
{
    return sprintf('%s/%s/%s',
        Config::get('static.images.' . $base), //url or path
        Config::get('static.images.original'),
        $image->category->slug
    );
}

private static function _thumb(Image $image, $base, $template)
{
    $image_path = sprintf('%s/%s', $image->id % 100, ($image->id / 100) % 100);

    return sprintf('%s/%s/%s/%s',
        Config::get('static.images.' . $base), //url or path
        Config::get('static.images.thumbnail'),
        $template,
        $image_path
    );
}


interface ImagePathService {

public function getOriginalPath(Image $image);

public function getThumbnailPath(Image $image);

public function getOriginalUrl(Image $image);

public function getThumbnailUrl(Image $image);
}

Best practices for custom helpers on Laravel 5

Community
  • 1
  • 1