Viewing 15 replies - 16 through 30 (of 34 total)
  • Thread Starter Andrew Leonard

    (@andrewleonard)

    Dear Ziya
    Not sure what it is you want to do exactly
    If you just want to show the images, you wrap your urls in html for example
    <img src=”https://www.ps4home.com/wp-content/uploads/2013/10/NO-BOX-ART.jpg”/&gt;
    You do this in the TablePress cell
    I have done this here:
    https://ebps.org.uk/publications/special-publications
    Does this answer your problem?
    If not then I can explain more about add_filter

    Dear Andrew,

    Thanks for replying

    I want same thing that you have done.

    The only difference is that you have done for a specific column value while I want do this for all row values for 2 columns.

    Thanks,
    Ziya

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi Ziya,

    then, you’ll just need an “or” in your if expression.

    Can you maybe post the code that you are using now, so that we can debug it? It should be pretty similar to the code from above.

    Regards,
    Tobias

    I am using following code

    add_filter( ‘tablepress_cell_content’, ‘Google_Wrap15’, 10, 4 );
    function Google_Wrap15( $tablepress_cell_content, $table_id, $row_number, $column_number ) {
    if ($table_id==1) {
    if ($column_number==8 or $column_number==9) {
    $x=strpos($tablepress_cell_content, ‘(‘);
    if ($x==0) {$temp=$tablepress_cell_content;}
    else {$temp=substr($tablepress_cell_content,0,$x);}
    $tablepress_cell_content = ‘<img src=”‘.$tablepress_cell_content.'”/>’;
    }
    }
    return $tablepress_cell_content;
    }

    Thread Starter Andrew Leonard

    (@andrewleonard)

    You want to remove these lines:
    $x=strpos($tablepress_cell_content, ‘(‘);
    if ($x==0) {$temp=$tablepress_cell_content;}
    else {$temp=substr($tablepress_cell_content,0,$x);}

    The it should work

    Thread Starter Andrew Leonard

    (@andrewleonard)

    Also I think the line should be:

    $tablepress_cell_content = “<img src=”.$tablepress_cell_content.”/>”;

    Thanks for your help

    It’s working on Mozila / Firefox but not working on chrome.

    URL – https://www.gamesage.co.uk/?page_id=8

    I am using following function

    add_filter( ‘tablepress_cell_content’, ‘Google_Wrap15’, 2, 8 );
    function Google_Wrap15( $tablepress_cell_content, $table_id, $row_number, $column_number ) {
    if ($table_id==1) {
    if($row_number >= 2) {
    if ($column_number==8) {
    $tablepress_cell_content = ‘<img width=”50″ height=”50″ src=”‘.$tablepress_cell_content.'”/>’;
    } else if ($column_number==9){
    $includes_images_url = includes_url().’images/buy_now.png’;
    $tablepress_cell_content = ‘<img width=”72″ height=”32″ src=”‘.$includes_images_url.'”/>‘;
    }
    }
    }
    return $tablepress_cell_content;
    }

    Thread Starter Andrew Leonard

    (@andrewleonard)

    Whoa!
    Column 8 is an image so the above code should work but column 9 is a link so you need code that looks like this:

    $tablepress_cell_content = “click here“;

    Of course you can put anything in “click here” including a link to an image as in <img src=’https://yourpath/camera.png’&gt;

    Thread Starter Andrew Leonard

    (@andrewleonard)

    It does not work for me in IE, Chrome or Firefox

    Thread Starter Andrew Leonard

    (@andrewleonard)

    Try this – I would copy and paste it from the email

    add_filter( ‘tablepress_cell_content’, ‘ziyaindia78_table1’, 10, 4 );
    function ziyaindia78_table1( $tablepress_cell_content, $table_id, $row_number, $column_number )
    {
    if ($table_id==1) {
    if($row_number >1) {
    if ($column_number==8) {
    $tablepress_cell_content = “<img width=’50’ height=’50’ src='”.$tablepress_cell_content.”‘/>”;
    } else if ($column_number==9){
    $tablepress_cell_content = “click here“;
    }
    }
    }
    return $tablepress_cell_content;
    }

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    nice progress here!

    Please try this, which I reformatted a little bit and where I made the naming more consistent:

    add_filter( 'tablepress_cell_content', 'ziya_wrap_images', 10, 4 );
    function ziya_wrap_images( $cell_content, $table_id, $row_number, $column_number ) {
    	if ( '1' == $table_id ) {
    		if ( $row_number > 1 ) {
    			if ( 8 == $column_number ) {
    				$cell_content = '<img width="50" height="50" src="' . esc_url( $cell_content ) . '"/>';
    			} elseif ( 9 == $column_number ) {
    				if ( 'TBA' !== $cell_content ) {
    					$image_url = includes_url() . 'images/buy_now.png';
    					$image_html = '<img width="72" height="32" src="' . esc_url( $image_url ) . '"/>';
    					$cell_content = '<a href="' . esc_url( $cell_content ) . '">' . $image_html . '</a>';
    				}
    			}
    		}
    	}
    	return $cell_content;
    }

    Note that you’ll have to save the table after making changes to this code (or wait 12 hours) to clear the cache.

    Regards,
    Tobias

    Dear Tobias / Andrew

    Thanks for all your reply but still images are not displaying on chrome.

    https://www.gamesage.co.uk/?page_id=8

    Thanks in advance,
    Ziya

    Dear Tobias / Andrew

    Please check

    Thanks,
    Ziya

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi Ziya,

    where have you added this PHP code now? Is it working in other browsers? That would be strange, as I can’t see any changes on the page here. Or are you maybe using a caching plugin that could be influencing this?

    Regards,
    Tobias

Viewing 15 replies - 16 through 30 (of 34 total)
  • The topic ‘Adding HTML to tables’ is closed to new replies.