Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Removed config opiton for responsive image sizes attribute - not need…
Browse files Browse the repository at this point in the history
…ed for now.
  • Loading branch information
szymonkups committed Jun 21, 2017
1 parent aa5d9f4 commit 75b8b41
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
9 changes: 2 additions & 7 deletions src/image/imageengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export default class ImageEngine extends Plugin {
const schema = doc.schema;
const data = editor.data;
const editing = editor.editing;
const config = editor.config;
const t = editor.t;

// Configure schema.
Expand All @@ -55,17 +54,13 @@ export default class ImageEngine extends Plugin {
createImageAttributeConverter( [ editing.modelToView, data.modelToView ], 'src' );
createImageAttributeConverter( [ editing.modelToView, data.modelToView ], 'alt' );

// Responsive sizes default value. More information and discussion on this topic:
// https://github.com/ckeditor/ckeditor5-image/issues/2.
config.define( 'image.responsiveSizes', '100vw' );
const sizes = config.get( 'image.responsiveSizes' );

// Convert `srcset` attribute changes and add or remove `sizes` attribute when necessary.
createImageAttributeConverter( [ editing.modelToView, data.modelToView ], 'srcset', ( viewImg, type ) => {
if ( type == 'removeAttribute' ) {
viewImg.removeAttribute( 'sizes' );
} else {
viewImg.setAttribute( 'sizes', sizes );
// Always outputting `100vw`. See https://github.com/ckeditor/ckeditor5-image/issues/2.
viewImg.setAttribute( 'sizes', '100vw' );
}
} );

Expand Down
20 changes: 0 additions & 20 deletions tests/image/imageengine.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,26 +394,6 @@ describe( 'ImageEngine', () => {
);
} );

it( 'should use sizes from configuration', () => {
return VirtualTestEditor.create( {
plugins: [ ImageEngine ],
image: {
responsiveSizes: '50vf'
}
} )
.then( newEditor => {
setModelData( newEditor.document,
'<image src="foo.png" alt="alt text" srcset="small.png 148w, big.png 1024w"></image>'
);

expect( getViewData( newEditor.editing.view, { withoutSelection: true } ) ).to.equal(
'<figure class="image ck-widget" contenteditable="false">' +
'<img alt="alt text" sizes="50vf" src="foo.png" srcset="small.png 148w, big.png 1024w"></img>' +
'</figure>'
);
} );
} );

it( 'should remove sizes attribute when srcset attribute is removed', () => {
setModelData( document, '<image src="foo.png" srcset="small.png 148w, big.png 1024w"></image>' );
const image = document.getRoot().getChild( 0 );
Expand Down

0 comments on commit 75b8b41

Please sign in to comment.