Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable image auto dimensions but keep dimensions input box #6473

Open
ghost opened this issue Jan 28, 2021 · 3 comments
Open

Disable image auto dimensions but keep dimensions input box #6473

ghost opened this issue Jan 28, 2021 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 28, 2021

When upload image on mobile phone, the editor always put screen width as dimensions width automatically.
We wish it looks bigger on computer, so anyway to disable auto dimensions.
There is an option: https://www.tiny.cloud/docs/plugins/opensource/image/#image_dimensions
To disable image_dimensions, the dimensions input box will disappear as well, but we want to keep it.

Here's a solution to disable auto dimensions (Provided by https://assbbs.com)

setup:function(editor){
editor.on(\'OpenWindow\',function(e){
var lock=document.querySelector(\'.tox-lock\');
if(lock){
var height_input=lock.parentNode.previousElementSibling.querySelector(\'input\');
var width_input=lock.parentNode.previousElementSibling.previousElementSibling.querySelector(\'input\');
var getter=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,\'value\').get;
var setter=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,\'value\').set;
var srcurl=lock.parentNode.parentNode.parentNode.parentNode.querySelector(\'input[type="url"]\');
var raito=0;if(width_input.value && height_input.value){raito=width_input.value/height_input.value;}
Object.defineProperty(width_input,\'value\',{set(val){},get(){return getter.call(this);}});
Object.defineProperty(height_input,\'value\',{set(val){},get(){return getter.call(this);}});
srcurl.addEventListener(\'input\',function(){setter.call(width_input,\'\');setter.call(height_input,\'\');raito=0;});
width_input.addEventListener(\'input\',function(){if(raito && document.querySelector(\'.tox-locked\')){setter.call(height_input,(getter.call(width_input)/raito).toFixed());};});
height_input.addEventListener(\'input\',function(){if(raito && document.querySelector(\'.tox-locked\')){setter.call(width_input,(getter.call(height_input)*raito).toFixed());};});
};
});
}

However it seems too complex and uses extra code hack.
Is it possible to provide an official option about this?
Thanks a lot!

Best

@lostkeys
Copy link
Member

Hi @unknown202101! Thanks for your feedback. Yes, there are room for improvements and I have flagged your feedback as a feature request, but unfortunately I can't provide any additional if or when we get to address this. We'll keep you updated here.

@bhalahariharan
Copy link

Hi. Is there any update on this, please?

@tiny-stale-bot
Copy link
Collaborator

This issue is stale because it has been open 365 days with no activity. Please comment if you wish to keep this issue open or it will be closed in 30 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants