management

Leveraging React for Easy Image Management

React is a good tool when it comes to building flexible and reusable UI components. However, it’s “one of those libraries” that cannot handle all the tasks involved in building a full fleshed UI project. Other supporting tools - such as a recently announced React SDK from Cloudinary - are available to provide solutions that the React core cannot.

In such cases where media (images and videos) becomes a heavy task to handle, Cloudinary simplifies the process with the new React SDK. Let’s build and image library with Cloudinary and React using the Cloudinary’s React SDK.

Prerequisites

The only requirements for using Cloudinary in your existing React project are to install the React SDK and the upload widget. If you do not have an existing React project and want to try these examples, take the following steps:

1. Install Dependencies

We need a minimal amount of dependencies so we can focus on building a media library and not structuring a React app:

{
  "name": "img-library",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "watch": "webpack -d --watch",
    "build": "webpack",
    "serve": "serve ./public"
  },
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "babel-core": "^6.18.2",
    "babel-loader": "^6.2.9",
    "babel-preset-es2015": "^6.18.0",
    "babel-preset-react": "^6.16.0",
    "serve": "^1.4.0",
    "webpack": "^1.14.0"
  },
  "dependencies": {
    "axios": "^0.15.3",
    "cloudinary-react": "^1.0.1",
    "react": "^15.4.1",
    "react-dom": "^15.4.1"
  }
}

React (and React DOM) must be used since we are making a React app. The cloudinary-react dependency is Cloudinary’s React SDK, which we will soon see how it works. axios is a tool for making HTTP requests and, in our case, we will use it request images from the Cloudinary server.

# Install dependencies
npm install

2. Setup Webpack

Webpack is our build tool. Only minimal settings are required to have a build running and our React app compiling:

// ./webpack.config.js
var webpack = require('webpack');
var path = require('path');

var BUILD_DIR = path.resolve(__dirname, 'public');
var APP_DIR = path.resolve(__dirname, 'src');

var config = {
    entry: APP_DIR + '/index.jsx',
    output: {
        path: BUILD_DIR,
        filename: 'bundle.js'
    },
    module : {
        loaders : [
            {
                test : /.jsx?/,
                include : APP_DIR,
                loader : 'babel'
            }
        ]
    }
};

module.exports = config;

Basic configuration - an entry, output and loaders to handle the React .jsx files.

3. Entry Points

We need to create an entry point, as we specified in the Webpack configuration, and another entry point for the browser, which is an index.html file:

// ./src/index.jsx
import React, { Component } from 'react';
import { render } from 'react-dom';

class Main extends Component {
    render() {
        return (
           <div className="main">
               <h1>Scotchage</h1>
           </div>
        );
    }
}

render(<Main />, document.getElementById('container'));
<!-- ./public/index.html -->
<html>
<head>
    <!--Stylesheet-->
    <link rel="stylesheet" href="style.css">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
    <!--Container for React rendering-->
    <div id="container"></div>
    <!--Bundled file-->
    <script src="bundle.js"></script>
</body>
</html>

4. Create Cloudinary Account

You need a Cloudinary account to continue with these examples. Sign up for free and store your credentials safely as shown on the dashboard:

Uploading Images

Before using the React SDK to deliver images from the Cloudinary servers, let’s use the awesome Cloudinary upload widget to upload images. First, we need to add this widget to our index.html:

<!-- ./public/index.html -->
<html>
<head>
   . . .
</head>
<body>
    . . .
    <!-- UPLOAD WIDGET -->
    <script src="//widget.cloudinary.com/global/all.js" type="text/javascript"></script>
    <script src="bundle.js"></script>
</body>
</html>

Next, we create a button, attach an event to it and upload an image once the button is clicked:

import React, { Component } from 'react';
import { render } from 'react-dom';

class Main extends Component {

    uploadWidget() {
        cloudinary.openUploadWidget({ cloud_name: 'CLOUD_NAME', upload_preset: 'PRESET', tags:['xmas']},
            function(error, result) {
                console.log(result);
            });
    }
    render(){
        return (
            <div className="main">
                <h1>Galleria</h1>
                <div className="upload">
                    <button onClick={this.uploadWidget.bind(this)} className="upload-button">
                        Add Image
                    </button>
                </div>
            </div>

        );
    }
}

render(<Main />, document.getElementById('container'));

The uploadWidget member method is the handler invoked by the click event to handle our image upload by calling cloudinary.openUploadWidget. openUploadWidget takes a config object and the upload callback handler. The config object must have at least cloud_name and upload_preset properties with valid values. You can read more about Cloud Names and Upload Presets.

Delivering Images with SDK

The Cloudinary React SDK has three major components, Image, CloudinaryContext and Transformation:

  • Image: This component is responsible for the actual delivery of images. It takes the image ID and asks the server for this image. When the image is provided, it is also responsible for painting the image on the browser.
  • Transformation: This component is used to apply transformations to images delivered with Image.
  • CloudinaryContext: You can specify Cloudinary configuration for each image on the Image component. This can be tedious when you are dealing with multiple images. CloudinaryContext allows you to apply configuration to a group of Images.

Most times you would end up with a structure like this:

<CloudinaryContext>
    <Image>
        <Transformation />
        <Transformation />
    </Image>
    <Image>
        <Transformation />
    </Image>
</CloudinaryContext>

Back to our demo app, we can request an image from the Cloudinary server and display it with the following components:

import React, { Component } from 'react';
import axios from 'axios';
import { CloudinaryContext, Transformation, Image } from 'cloudinary-react';
import { render } from 'react-dom';

class Main extends Component {
    constructor(props) {
        super(props);
        this.state = {
            gallery: []
        }
    }
    componentDidMount() {
    // Request for images tagged xmas       
axios.get('http://res.cloudinary.com/christekh/image/list/xmas.json')
            .then(res => {
                console.log(res.data.resources);
                this.setState({gallery: res.data.resources});
            });
    }
    uploadWidget() {
       // . . .
    }
    render(){
        return (
            <div className="main">
                <h1>Galleria</h1>
                <div className="gallery">
                    <CloudinaryContext cloudName="CLOUDNAME">
                        {
                            this.state.gallery.map(data => {
                                return (
                                    <div className="responsive" key={data.public_id}>
                                        <div className="img">
                                            <a target="_blank" href={`http://res.cloudinary.com/christekh/image/upload/${data.public_id}.jpg`}>
                                                <Image publicId={data.public_id}>
                                                    <Transformation
                                                        crop="scale"
                                                        width="300"
                                                        height="200"
                                                        dpr="auto"
                                                        responsive_placeholder="blank"
                                                    />
                                                </Image>
                                            </a>
                                            <div className="desc">Created at {data.created_at}</div>
                                        </div>
                                    </div>
                                )
                            })
                        }
                    </CloudinaryContext>
                    <div className="clearfix"></div>
                </div>
            </div>

        );
    }
}

render(<Main />, document.getElementById('container'));

Take one more look at the upload code:

 cloudinary.openUploadWidget({ cloud_name: 'christekh', upload_preset: 'idcidr0h', tags:['xmas']},
            function(error, result) {
            . . .

Each image is tagged with xmas, which serves as a way to request images with this tag as a collection. This is exactly what we are using the axios library to do when the component mounts:

axios.get('http://res.cloudinary.com/CLOUDNAME/image/list/xmas.json')
            .then(res => {
                console.log(res.data.resources);
                this.setState({gallery: res.data.resources});
            });

axios uses promises, so whenever the promise resolves in our case, we have a payload of images. We take advantage of React state to update our UI with the fetched resources.

Down to rendering, we configure the CloudinaryContext with our cloud_name, iterate over the gallery state that stores the images and displays them using the Image component. We also apply few transformations using the Transformation component.

For security reasons, Cloudinary will not allow you to make such request from the client unless you tell it to. The best way to go is to use the admin API via a backend SDK and then send the resource list to the client.

Updating State with New Uploads

We are able to upload images and request for images to be displayed on the user’s browsers. Here is how we update the displayed images instantly when the user uploads a new image:

uploadWidget() {
        let _this = this;
        cloudinary.openUploadWidget({ cloud_name: 'CLOUDNAME', upload_preset: 'PRESET', tags:['xmas']},
            function(error, result) {
            // Update gallery state with newly uploaded image
                _this.setState({gallery: _this.state.gallery.concat(result)})
            });
    }

Rather than logging the uploaded image information to the console, we update the gallery state, which bears the list of requested images, by concatenating the uploaded result to the gallery.

Image Management Simplified

Image uploads, transformation and delivery has never been easier. These tasks have been a serious challenge for developers. Cloudinary has created a way to abstract all this hard work, enabling you to simply plug and play.




management

COVID-19: Guidelines on Dead Body Management

Highlights : In India, over 17,265 confirmed novel coronavirus disease (COVID-19) cases and 543 deaths as of yesterd




management

CEA partners with IWMI to improve Colombo’s municipal waste management and farmers’ access to organic fertilizers

Colombo, December 10, 2013. At the request of the Colombo Municipal Council (CMC), the Central Environmental Authority (CEA), in collaboration with the International Water Management Institute (IWMI), organized a stakeholder meeting to discuss improvements that can be made to the management of municipal waste in the City of Colombo. The meeting was held at the […]




management

Press Release: Sustainable Development Goals Offer Unique Opportunity to Transform Management of Critical Water Resources

Targets that promote efficient, nationally and locally appropriate water use will be key to achieving the SDGs.




management

Press Release: Satellite imaging and disaster management experts gather in Colombo

Experts from across Asia gathered to discuss how the next generation of satellite based technologies could help improve disaster preparedness and response at a three-day meeting in Mount Lavinia.




management

PreventiOnWeb.net: Change in behaviour needed for improved drought management in Jordan and the MENA region

To better understand the risk factors and the effects of drought in the region, IWMI conducted a survey of 400 commercial fruit farms in Jordan, one the most water-scarce countries in the world.



  • IWMI in the news

management

Devex: How satellite images could improve water management in Africa

“One of the big challenges of dealing with water resource management is: How are you going to manage something if you can't measure it?” said William Rex, senior adviser at the International Water Management Institute.




management

Developing Telecoms: Satcoms to support African water management

A welcome piece of positive news for Africa comes from the Sri Lanka-headquartered International Water Management Institute (IWMI) and a new satellite data initiative.




management

WaterPartnership.org.au: AWP and IWMI to collaborate on water management across the Asia-Pacific

Strengthening DFAT and AWP’s partnership with IWMI provides the opportunity for working more closely together on critical water challenges facing the region







management

SundayTimes.lk: Better waste management options explored at NIBM workshop

The International Water Management Institute (IWMI) was a valued partner in conceptualising the workshop content and was well represented at the workshop with the participation of its senior officials.





management

Devex: How satellite images could improve water management in Africa

“One of the big challenges of dealing with water resource management is: How are you going to manage something if you can't measure it?” said William Rex, senior adviser at the International Water Management Institute.




management

Developing Telecoms: Satcoms to support African water management

A welcome piece of positive news for Africa comes from the Sri Lanka-headquartered International Water Management Institute (IWMI) and a new satellite data initiative.




management

Community water management and agricultural extension services: effects, impacts and perceptions in the coastal zone of Bangladesh

The coastal region of Bangladesh is prone to natural disasters and these events are expected to worsen as a result of climate change.




management

Metabolic Health and Weight Management Reduce Diabetes Risk

Being metabolically unhealthy raises diabetes risk as increased fat distribution contributes to insulin resistance, even in women of normal weight, according




management

Diabetes Support Groups Linked to Lower Levels of Disease Management

Type 2 diabetes patients belonging to OSGs (online support groups) to share experiences and glean information were found to have poorer health, said a




management

HDFC Asset Management Company Limited - Analysts/Institutional Investor Meet/Con. Call Updates

HDFC Asset Management Company Limited has informed the Exchange regarding Analysts/Institutional Investor Meet/Con. Call Updates - Revised......




management

HDFC Asset Management Company Limited - Financial Result Updates

HDFC Asset Management Company Limited has submitted to the Exchange, the financial results for the period ended March 31, 2020.......




management

HDFC Asset Management Company Limited - Outcome of Board Meeting

HDFC Asset Management Company Limited has informed the Exchange regarding Outcome of Board Meeting held on May 09, 2020. The Board of Directors in the said meeting has recommended a dividend......




management

HDFC Asset Management Company Limited - Investor Presentation

HDFC Asset Management Company Limited has informed the Exchange regarding Investor Presentation along with Press Release for the quarter and year ended March 31, 2020.......




management

Hotel Asset Management – In Good Times and Bad

The practice of asset management for hotels entering the third decade of the 21st Century has evolved into an intricate process of analyzing layers of data and operating results, and then acting based upon the conclusions. The process requires great...




management

Immediate openings in USA For Hotel Management professionals:

Company: 2COMS Consulting Private Limited
Experience: 0 to 2
location: US
Ref: 24826650
Summary: mmediateopeningsinUSAforHotelManagementprofessionals: Dept:Hospitality (Htousekeeping Associate) Industry:HotelIndustry Salary:1600USDto1800USD+AttractiveincentivesforOT Qualification:BachelorofHotelManagement (2019) Fees....




management

Hospitality Executive (Hotel Management)

Company: 2COMS Consulting Private Limited
Experience: 1 to 2
location: US
Ref: 24826643
Summary: Immediate openings in USA for Hotel Management professionals: Dept : Hospitality Industry : Hotel Industry Salary : 1600USD to 1800 USD + Attractive incentives for OT Qualification : Bachelor of Hotel Management candidates should....




management

Golden Opportunity For Hotel Management at USA (america) !!!

Company: 2COMS Consulting Private Limited
Experience: 0 to 5
location: Delhi NCR, Delhi
Ref: 24826634
Summary: Golden Opportunity For Hotel Management at USA (America) !!!, Position: Hotel Management Location: America (USA) Experience; 0 to 5 years (only BHM Candidates) Salary: ....




management

Hospitality Executive (Hotel management)

Company: 2COMS Consulting Private Limited
Qualification: Bachelor in Hotel Management (B.H.M)
Experience: 1 to 2
Salary: 12.00 to 14.00
location: US
Ref: 24825348
Summary: Immediate openings in USA for Hotel Management professionals: Dept : Hospitality Industry : Hotel Industry Salary : 1600USD to 1800....




management

Immediate openings in USA for Hotel Management professionals

Company: 2COMS Consulting Private Limited
Qualification: Bachelor in Hotel Management (B.H.M)
Experience: 0 to 2
location: US
Ref: 24825125
Summary: Dept : Hospitality (Htousekeeping Associate) Industry : Hotel Industry Salary : 1600USD to 1800 USD + Attractive incentives for OT Qualification : Bachelor of....




management

Program Management-Transition

Company: Golden Opportunities Private Limited
Experience: 6 to 9
location: Chennai
Ref: 24827463
Summary: Description Transition specialist Job Role: Should manage internal / external client relationships during various stages of the transition Must have Working experience as the Transition Manager for Digital Operations....




management

Program Management-Transition

Company: Golden Opportunities Private Limited
Experience: 6 to 8
location: Mumbai
Ref: 24827454
Summary: Description Transition specialist Job Role: Should manage internal / external client relationships during various stages of the transition Must have Working experience as the Transition Manager for Digital Operations....




management

Knowledge Management Specialist

Company: Golden Opportunities Private Limited
Experience: 2 to 6
location: Mumbai
Ref: 24813879
Summary: Minimum 2 years of experience in Content writing and content creation experience required




management

Sr.Analyst (Clincial Data Management)

Company: Golden Opportunities Private Limited
Experience: 4 to 10
location: Bengaluru / Bangalore, Hyderabad / Secunderabad
Ref: 24826365
Summary: We have an immediate opening in one of the Best MNC's in India for the Role of "Clinical Data Management" for Hyderabad and Bengaluru Location having the largest....




management

Complaints Management TM

Company: Golden Opportunities Private Limited
Experience: 8 to 13
location: Kolkata
Ref: 24249778
Summary: Description 8+ years of relevant experience Complaints Management for the role Team Manager kolkata Skill Set: Team handling skill is a must. Organizational skills and ability to strategize optimal team performance Quality....




management

Silent technical advancement noteworthy in school management software

Of course, there are different software vendors in the market to manage administration works of different industries. If you think that school software is chiefly to manage records, process payroll and maintain attendance, then you are...




management

Openings for Logistics/SCM/Order management

Company: Diraa HR Services
Qualification: Other
Experience: 0 to 5
location: Coimbatore
Ref: 24382145
Summary: A Logistics Manager supervises the movement, distribution and storage of supplies and materials in a company. They are tasked with planning routes, analyzing budgets, and processing shipments.




management

Quick Management Lesson


Ek din ek kutta jungle main raasta kho




management

Akamai Revolutionizes Bot Management

Akamai Revolutionizes Bot Management




management

Universal GmbH Awards ISO 9001-2008 Quality Management Certificate to MRSS

Universal GmbH (UNICERT) has certified MRSS, a leading digital market research company to DIN EN ISO 9001 - 2008 for successful application of quality management throughout its entire organization.




management

Contract Management

Company: Golden Opportunities Private Limited
Experience: 3 to 6
location: Bengaluru / Bangalore
Ref: 24399905
Summary: Description Drafting and reviewing of the contracts with analyzing the risks and issues in the contracts. Managing database of the contracts Drafting contracts ? Drafting Master Service Agreements, Addendums,....




management

Contract Management (Fresher)

Company: Golden Opportunities Private Limited
Experience: 0 to 3
location: Bengaluru / Bangalore
Ref: 24399900
Summary: Description Drafting and reviewing of the contracts with analyzing the risks and issues in the contracts. Managing database of the contracts Drafting contracts ? Drafting Master Service Agreements, Addendums,....




management

Human Resources Management: Country Profiles

These country notes profile public sector human resource practices and policies, covering issues including legal frameworks; age and gender composition of workers; public sector restructuring; management practices; industrial relations and reforms.




management

Director Project Management

Company: Future Enterprises
Experience: 12 to 20
Salary: 30.00 to 50.00
location: Chandigarh
Ref: 24828218
Summary: - Minimum 12 years of project management experience with at least 5 years of experience in leadership role.




management

IT Security Analyst I - PKI/Venafi - Certificate Management

Company: FIS Global Business Solutions India Private Limited
Experience: 1 to 4
location: India
Ref: 24827890
Summary: Job Description : Position Type : Full time Type Of Hire : Experienced (relevant combo of work and education) Education Desired : Bachelor's Degree Travel Percentage : 0% Are you curious, motivated, and....




management

IT Security Analyst Senior - PKI/Venafi - Certificate Management

Company: FIS Global Business Solutions India Private Limited
Experience: 5 to 8
location: India
Ref: 24827885
Summary: Job Description : Position Type : Full time Type Of Hire : Experienced (relevant combo of work and education) Education Desired : Bachelor of Computer Science Travel Percentage : 0% Are you curious, motivated,....




management

Employee Data Management

Company: Golden Opportunities Private Limited
Experience: 3 to 12
location: Mumbai
Ref: 24825731
Summary: Graduates with 3+ years of relevant experience in Employee Data Management from International BPO operations only.




management

The Role and Management of Quality in Competition Analysis, 2013

This document compiles the material discussed in a competition policy roundtable on quality in competition analysis, including a summary of the discussion, country contributions, a background note and expert contribution on how quality factors are handled under U.S. law in the litigated assessment of the competitive effects of resale price maintenance.




management

High-level seminar on capital flow management and liberalisation: the role of international co-operation

This seminar aimed to advance shared understandings on policies to make the most of cross-border capital flows in support of growth and development and on the value of international co-operation, including the OECD Codes of Liberalisation, in the current context of serious global financial turbulence.




management

The OECD's approach to capital flow management measures used with a macro-prudential intent

This report responds to a request from the G20 that the IMF and OECD assess whether further work is needed on their respective approaches to measures which are both macro-prudential and capital flow measures, taking into account their individual mandates. The report was transmitted to G20 Finance Ministers and Central Bank Governors at their meeting on 16-17 April 2015 in Washington D.C.




management

Co-operation on approaches to macro-prudential and capital flow management measures: Update by the IMF and the OECD

This update report by the IMF and the OECD was delivered to G20 in February 2016.