Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
wordpress-query-media
Advanced tools
Readme
This package contains a query component, along with redux state & selectors for media pulled from a WordPress site. This uses the node-wpapi
package to get your site's data via Query Components (inspired by calypso). The Query Components call the API, which via actions set your site's data into the state.
To use any of these helpers, you'll need to set your Site URL in a global (SiteSettings
), so that the API knows what site to connect to. For example:
window.SiteSettings = {
endpoint: 'url.com/path-to-wordpress',
};
Query Media is a React component used in managing the fetching of media items.
Render the component, passing in the attachmentId
. It does not accept any children, nor does it render any elements to the page. You can use it adjacent to other sibling components which make use of the fetched data made available through the global application state.
import React from 'react';
import QueryMedia from 'wordpress-query-media';
import MyMediaItem from './media-item';
export default function MyMediaComponent( { media } ) {
return (
<div>
<QueryMedia attachmentId={ 32 } />
<MyMediaItem media={ media } />
</div>
);
}
attachmentId
Type | Number |
---|---|
Required | Yes |
Default | null |
The attachment ID of the requested media item
You can import these into your project by grabbing them from the selectors
file:
import { getMedia, isRequestingMedia } from 'wordpress-query-media/lib/selectors';
getMedia( state, globalId )
isRequestingMedia( state, path )
If you need access to the reducers, action types, or action creators, you can import these from the state
file. For example, to use this in your global redux state, mix it into your reducer tree like this:
import media from 'wordpress-query-media/lib/state';
let reducer = combineReducers( { ...otherReducers, media } );
If you need to call an action (the query component should take care of this most of the time), you can pull the action out specifically:
import { requestMedia } from 'wordpress-query-media/lib/state';
View the file itself to see what else is available.
FAQs
A component for fetching WordPress media data from the REST API.
We found that wordpress-query-media demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).