Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

368
Vistas
Filter Slider is not working unless I'm in the back end, changing the code

I have filter sliders that change Contrast, Saturation, and Hue of a selected image. They were all working great a few months ago. WordPress updated a lot since December. Now they don't work.

While I'm in the back-end, I can get them to function perfectly by changing any little thing. I can move the position of the JavaScript or put in one letter and delete it from the JavaScript and it will suddenly work. In WordPress you have these HTML bubbles you put code in, and I can change any of the other 4 JavaScript sections within the same bubble and it'll start working again.

All 4 of the other (separated) processes within that bubble work just fine without prompting, though none of them are sliders like these.

I have tried changing the starting position of the JS up and down the page from the HTML and nothing corrected the sliders (though a higher starting position did cause my other buttons to fail).

I have tried adding document.ready() but that broke the sliders fully.

The HTML filter sliders:

<span class="sliders">
            <label class="label1 sliders">Contrast</label>
                <input type="range" min="90" max="120" value="100" step="1" onchange="applyFilter()" data-filter="contrast" data-scale="%"><br>
            </span>
        <span class="sliders">
            <label class="label2 sliders">Saturation</label>
                <input type="range" min="70" max="200" value="100" step="1" onchange="applyFilter()" data-filter="saturate" data-scale="%"><br>
        </span>
        <span class="sliders">
            <label class="label3 sliders">Color</label>
                <input type="range" min="-22" max="22" value="0" step="1" onchange="applyFilter()" data-filter="hue-rotate" data-scale="deg"><br>
        </span>

The javascript to make them work:

<script type="text/javascript">
        var image = document.querySelector('.pic');
        var filterControls = document.querySelectorAll('input[type=range]');
        function applyFilter() {
            var computedFilters = '';
            filterControls.forEach(function(item, index) {
                computedFilters += item.getAttribute('data-filter') + '(' + item.value + item.getAttribute('data-scale') + ') ';
                 });
                 image.style.filter = computedFilters;
            };
            
    </script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

After Digging through the code I found that I had this for a different photo-set on the same page. The variables are identical to the ones in my problem zone, but these are located lower on the page, so this set of controls worked.

<script type="text/javascript">
        var image = document.querySelector('.pic-resin-coaster');
        var filterControls = document.querySelectorAll('input[type=range]');
        function applyFilterResin() {
            var computedFilters = '';
            filterControls.forEach(function(item, index) {
                computedFilters += item.getAttribute('data-filter') + '(' + item.value + item.getAttribute('data-scale') + ') ';
                 });
                 image.style.filter = computedFilters;
            };
</script>

Once I changed them to be unique to this photo-set they started working on the front-end and back-end.

Final Variable look:

<script type="text/javascript">
        var imagerc = document.querySelector('.pic-resin-coaster');
        var filterControlsrc = document.querySelectorAll('input[type=range]');
        function applyFilterResin() {
            var computedFiltersrc = '';
            filterControlsrc.forEach(function(item, index) {
                computedFiltersrc += item.getAttribute('data-filter') + '(' + item.value + item.getAttribute('data-scale') + ') ';
                 });
                 imagerc.style.filter = computedFiltersrc;
            };
</script>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda