[resolved] Changing domain loose all the images. (2 posts)

  1. kadorrna
    Posted 3 years ago #

    Hi to everyone, I have change the domain and everything seems to works fine but the images in the database in the guid field still have the old domain, if I look the link in the admin panel the link seems ok, but in the database is not ok.

    Can somebody give me a hint?

    I had tried http://codex.wordpress.org/Moving_WordPress but nothing changed. The images still are not shown.

    Thanks in advance.

  2. kadorrna
    Posted 3 years ago #

    I have solved bringing the image in other way (better maybe)

    function getPostImageByTitle($postid, $imageName,$orderBy="DESC"){
    	global $wpdb;
    	$querystr = "SELECT ".$wpdb->posts.".* FROM ".$wpdb->posts." WHERE ".$wpdb->posts.".post_parent = ".$postid.
    	    " AND ".$wpdb->posts.".post_type = 'attachment'
    	    AND (".$wpdb->posts.".post_mime_type = 'image/png'
    	    		OR ".$wpdb->posts.".post_mime_type = 'image/gif' OR ".$wpdb->posts.".post_mime_type = 'image/jpeg')
    	    AND ".$wpdb->posts.".post_status = 'inherit'
    	    AND ".$wpdb->posts.".post_title = '".$imageName."'
    	    ORDER BY $wpdb->posts.post_date ".$orderBy;
    	$image = $wpdb->get_results($querystr, OBJECT);
    	if (sizeof($image) == 1){
    			//return $image[0]->guid;
    		if ($imageName == "post"){
    			echo "<img src='".get_bloginfo('template_url')."/images/homeGeneric.png' />";
    		}elseif ($imageName == "icon"){
    			echo "<img src='".get_bloginfo('template_url')."/images/notfound.png' />";

    Before I was returning the guid now I am using the_attachment_link function.


Topic Closed

This topic has been closed to new replies.

About this Topic