npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bootstrap-imageupload-src

v1.2.0

Published

A Bootstrap/jQuery plugin to preview image uploads.

Downloads

42

Readme

Warning: this repository is unmaintained. Fork at your own risk.

bootstrap-imageupload

A Bootstrap/jQuery plugin to preview image uploads.

Table of contents

Demo

https://nerdy-harry.github.io/bootstrap-imageupload

Installation

Following installation options are available:

  • Download and include the files manually.
  • Install with npm: npm install bootstrap-imageupload-src --save.

Usage

$('#my-imageupload').imageupload(options);

HTML

Copy this snippet into your HTML.

<div class="imageupload panel panel-default">
    <div class="panel-heading clearfix">
        <h3 class="panel-title pull-left">Upload Image</h3>
        <div class="btn-group pull-right">
            <button type="button" class="btn btn-default active">File</button>
            <button type="button" class="btn btn-default">URL</button>
        </div>
    </div>
    <div class="file-tab panel-body">
        <label class="btn btn-default btn-file">
            <span>Browse</span>
            <!-- The file is stored here. -->
            <input type="file" name="image-file">
        </label>
        <button type="button" class="btn btn-default">Remove</button>
    </div>
    <div class="url-tab panel-body">
        <div class="input-group">
            <input type="text" class="form-control" placeholder="Image URL">
            <div class="input-group-btn">
                <button type="button" class="btn btn-default">Submit</button>
            </div>
        </div>
        <button type="button" class="btn btn-default">Remove</button>
        <!-- The URL is stored here. -->
        <input type="hidden" name="image-url">
    </div>
</div>

JavaScript

Options

| Name | Type | Default | | ---------------|--------| ------------------------------| | allowedFormats | Array | ['jpg', 'jpeg', 'png', 'gif'] | | maxWidth | Number | 250 | | maxHeight | Number | 250 | | maxFileSizeKb | Number | 2048 | | imgSrc | String | '' |

Methods

.imageupload(options)

Initializes bootstrap-imageupload. If no options are given, defaults are used.

$('#my-imageupload').imageupload({
    allowedFormats: [ 'jpg' ],
    maxFileSizeKb: 512,
    imgSrc: "http://www.gstatic.com/webp/gallery/5.jpg"
});
.imageupload('disable')

Disables user input.

$('#my-imageupload').imageupload('disable');
.imageupload('enable')

Enables user input (after being disabled).

$('#my-imageupload').imageupload('enable');
.imageupload('reset')

Resets bootstrap-imageupload to its initial state. Options from initialization are preserved.

$('#my-imageupload').imageupload('reset');

Limitations

The upload image by URL feature has the following limitations:

  • The URL must contain the filename including its extension.
  • The file size cannot be verified.

These limitations exist because the image element constructor is used to load the image. The only accurate method to verify the image format and file size, is to perform a HTTP HEAD request, which might not work because of the same origin policy. In order to avoid loading very large image files, a timeout of 3000ms is used.