Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter mikeldev

    (@mikeldev)

    Oh yes,

    I wanted to ask this in comet cache plugin but I don’t know how I did here.
    I just confused for a second the plugins.
    Apologies!

    Thread Starter mikeldev

    (@mikeldev)

    Thanks.

    The alternative I found is to add hidden input elements with the value injected by PHP.

    Thread Starter mikeldev

    (@mikeldev)

    I did myself.

    
    // IE9+
    function onready(fn) {
    	if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){
    		fn();
    	} else {
    		document.addEventListener('DOMContentLoaded', fn);
    	}
    }
    
    onready(function(){
    	var target  = 'img.style-svg';
    	var images = document.querySelectorAll(target);
    
    	// IE9+
    	images.forEach(function(image, index){
    		var imgID = image.getAttribute('id'); // IE8+
    		var imgClass = image.getAttribute('class'); // IE8+
    		var imgURL = image.getAttribute('src'); // IE8+
    
    		if (!/.svg$/g.test(imgURL)) {
    			return;
    		}
    
    		// IE9+
    		var request = new XMLHttpRequest();
    		request.open('GET', imgURL, true);
    
    		request.onload = function() {
    			if (request.status < 200 || request.status >= 400) {
    				console.log('Target server reached but it returned an error');
    			} else {
    				// Get the SVG tag, ignore the rest
    				var svgWrapper = document.createElement("div");
    				svgWrapper.innerHTML = request.responseText;
    				var svg = svgWrapper.querySelector('svg');
    
    				// Add replaced image's ID to the new SVG if necessary
    				if(!imgID) {
    					var svgID = svg.getAttribute('id');
    					if(!svgID) { 
    						imgID = 'svg-replaced-'+index;
    						svg.setAttribute('id', imgID);
    					} else {
    						imgID = svgID;
    					}
    				} else {
    					svg.setAttribute('id', imgID);
    				}
    
    				// Add replaced image's classes to the new SVG
    				if(imgClass) {
    					svg.setAttribute('class', imgClass+' replaced-svg svg-replaced-'+index);
    				}
    
    				// Remove any invalid XML tags as per http://validator.w3.org
    				if (svg.hasAttribute('xmlns:a')) {
    					svg.removeAttribute('xmlns:a');
    				}
    
    				// Replace image with new SVG
    				image.outerHTML = svg.outerHTML; // IE8+
    
    				// Custom Trigger, IE9+
    				if (window.CustomEvent) {
    					var event = new CustomEvent('svg.loaded', [imgID]);
    				} else {
    					var event = document.createEvent('svg.loaded');
    					event.initCustomEvent('svg.loaded', true, true, [imgID]);
    				}
    
    				document.dispatchEvent(event);
    			}
    		};
    
    		request.onerror = function() {
    			console.log('There was a connection error of some sort');
    		};
    
    		request.send();
    	});
    });
    

    Same here.

    PHP version: 7.0.18-0ubuntu0.16.04.1
    WordPress version: 4.8.1
    Cloudinary plugin version: 1.1.6
    Parameters/configuration passed to cloudinary: Not parameters, just full image URL.
    Full error message/stack trace:

    This is what I have inside an inline css style:
    background-image: url('<br /> <b>Notice</b>: Undefined index: post-thumbnail in <b>/wp-content/plugins/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php</b> on line <b>296</b><br /> https://res.cloudinary.com/myId/image/upload/numericId/myFile.jpg')

    In the template I am adding that background image like this:

    style="background-image: url('<?php the_post_thumbnail_url(); ?>')"

    • This reply was modified 8 years, 9 months ago by mikeldev.
    • This reply was modified 8 years, 9 months ago by mikeldev.
Viewing 4 replies - 1 through 4 (of 4 total)