Skip to content

Commit

Permalink
fix image filtering case sensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
erquhart committed Nov 15, 2017
1 parent bf6eb2f commit 2a9697d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/components/MediaLibrary/MediaLibrary.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { connect } from 'react-redux';
import { orderBy, get, last, isEmpty, map } from 'lodash';
import { orderBy, get, isEmpty, map } from 'lodash';
import c from 'classnames';
import fuzzy from 'fuzzy';
import Waypoint from 'react-waypoint';
import Dialog from '../UI/Dialog';
import { resolvePath } from '../../lib/pathHelper';
import { resolvePath, fileExtension } from '../../lib/pathHelper';
import { changeDraftField } from '../../actions/entries';
import {
loadMedia as loadMediaAction,
Expand Down Expand Up @@ -53,16 +53,19 @@ class MediaLibrary extends React.Component {
/**
* Filter an array of file data to include only images.
*/
filterImages = files => {
return files ? files.filter(file => IMAGE_EXTENSIONS.includes(last(file.name.split('.')))) : [];
filterImages = (files = []) => {
return files.filter(file => {
const ext = fileExtension(file.name).toLowerCase();
return IMAGE_EXTENSIONS.includes(ext);
});
};

/**
* Transform file data for table display.
*/
toTableData = files => {
const tableData = files && files.map(({ key, name, size, queryOrder, url, urlIsPublicPath }) => {
const ext = last(name.split('.'));
const ext = fileExtension(name).toLowerCase();
return {
key,
name,
Expand Down

0 comments on commit 2a9697d

Please sign in to comment.