Quotes Collection
In the latest version of this plugin my images get removed. (5 posts)

  1. Martin1
    Posted 3 years ago #

    I added a small icon to each quote in an older version. Now I needed to update on quote and all of a sudden the image gets removed.

    I used this code

    a href="http://www.mysite.com/page1/"><img src="http://www.mysite.com/images/image1.png" align="left" style="padding: 0px 5px 105px 0px"></a
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vulputate felis ut nibh molestie in lobortis sapien rhoncus.

    (I removed the opening and closing brackets so the entire code would show)

    But now all that stays is the link and the image gets removed. What changed? How can I get my images back?


  2. tonesfrommars
    Posted 3 years ago #

    In the latest version(s) the developer has disallowed certain html elements by filtering through wp_kses_data(). The allowed tags are as follows (from kses.php in wp-includes dir)

    $allowedtags = array(
    		'a' => array(
    			'href' => true,
    			'title' => true,
    		'abbr' => array(
    			'title' => true,
    		'acronym' => array(
    			'title' => true,
    		'b' => array(),
    		'blockquote' => array(
    			'cite' => true,
    		'cite' => array(),
    		'code' => array(),
    		'del' => array(
    			'datetime' => true,
    		'em' => array (), 'i' => array (),
    'cite' => array()),
    		'q' => array(
    			'cite' => true,
    		'strike' => array(),
    		'strong' => array(),

    There are two functions in quotes-collection-admin.php which filter the quote data in this manner.. you would look for this:

    $quote = wp_kses_data( stripslashes($quote) );

    I believe the image tags you had in your quotes before will have been overwritten, so you'd have to re-enter them if you chose to modify the plugin. Of course, it goes without saying that if you do so, you won't be able to update it without losing that data again.

    I have adapted the plugin for my own purposes and this was one of the modifications I made.

    Hope tha helps!

  3. Martin1
    Posted 3 years ago #

    This is way above my comfort zone:-). I have no idea what you just said or what I need to do to get those images back.

    Would it be to much trouble to ask you to clarify a bit further like you would to a six year old :-).

  4. tonesfrommars
    Posted 3 years ago #

    Hi Martin1,

    In case I wasn't clear about it, there's no way to "get the images back". The image files are untouched, they haven't gone anywhere, but you will have to "insert" references to them into your quotes from scratch.

    The other stuff in my first post is just pointing you in the right direction if you wanted to modify the plugin. Given that you're telling me it didn't make sense, here's as simple as I can make it for you if you want to do a similar modification.

    One caveat... you should understand that the reason for this constraint in the first place is to prevent users from inputting poorly formed (or ill-advised) html into their quote content, which can break a page layout or worse). you have been warned! :-)

    So the simplest thing you could do is change two lines in the file: quotes-collection-admin.php

    These lines are 22 & 59. They are both identical.

    $quote = wp_kses_data( stripslashes($quote) );

    here's the line after your edit:

    $quote = wp_kses_post( stripslashes($quote) );

    This will allow all kinds of html tags (anything you can put into post content)

    So that's a quick and dirty fix (I'd say it qualifies as a hack)
    To do it more properly, you could define a global variable $myAllowedTags, copy the code from my first post, but add 'img' to the array with attributes 'src' and 'alt', then plug that into each function like this:

    global $myAllowedTags;
    $quote = wp_kses( stripslashes($quote), $myAllowedTags );

    Have fun!

  5. Martin1
    Posted 3 years ago #


    Thanks this works perfectly :-) and was just what I was looking for except for one detail I hope you know how to solve:-).
    I also added some html (strong and a span style color) to the author section which now longer works.

    Would you know how to get that working as well?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Quotes Collection
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic