How do you remove the image in OpenTBS if the one you are replacing it with does not exist?
I have a bit of code that loops through and replaces pics in a table, but sometimes the client will not have the pictures. I tried leaving out the default=current tag but it shows a missing image box("This image cannot currently be displayed").
UPDATE:
I thought Skrols answer would work but I couldnt get it to work. I have an image followed by the following tag.
[field.p5;ope=changepic;from=’[val]’;adjust]
Whats tags following this would i have to use to say if the field variable p5 is not set or empty ect then remove the image.
If your first need is to not change the picture in the Docx if the target picture is a not found file, then they are two solutions:
First try with the latest OpenTBS version (1.7.4) because it claims to fix a bug about "default=current"
If it does not work, then you have to check at the PHP side if the target picture does exist using file_exists(). If it doesn't exist then change the target picture path with a new file that you are sure it does exist.
If you prefer to delete the picture box in the document if the file is missing, then you can add a TBS field that will delete the picture box depending to a global variable.
PHP:
$picok = (file_exists($the_picture)) ? 1 : 0;
HTML:
[onshow;block=w:drawing;when [var.picok]=1]
Related
I'm using DOMPDF to generate several documents, and in the top left is an image that looks like this:
But whenever I generate the PDF there is a very small chance (let's say about 10%) that the image will look like this:
I have no idea why this happens. It doesn't happen to any other images in the document.
When I move the image a few pixles up or down, the white line moves as well, so it's not like there is a hidden element or something placed over the image.
Is this a known DOMPDF problem ?
It appears that this is caused by imagick. It can be disabled as follows:
Add the following line to "dompdf_config.custom.inc.php":
define("DOMPDF_ENABLE_IMAGICK", false);
And change line 4324 of "class.pdf.php" from:
elseif (extension_loaded("imagick")) {
to:
elseif (extension_loaded("imagick") && DOMPDF_ENABLE_IMAGICK) {
This solution worked for me
I found it here: https://github.com/dompdf/dompdf/issues/432
Thanks to BrianS
I am inserting data in WordPress from my php script, everything is going smooth but i am facing one big problem to set Featured image from external link. I have almost solve this problem by adding image link to wp_postmeta
I have added
_wp_attached_file with external image link
_thumbnail_id giving it post id of the link
it work fine ... but there a small problem ... image is getting defauld url+external image link
http://****.com/wp-content/uploads/http://i.imgur.com/waiBWaV.jpg
My Question is how can i remove default link http://****.com/wp-content/uploads/ so only external image link display and i get right image.
Thx
The easiest way is to use regular expression to trim unusefull part of url.
$src = 'http://****.com/wp-content/uploads/http://i.imgur.com/waiBWaV.jpg';
$image = preg_replace('|.*/(.*?\.[\w]+)|', '\1', $src);
to continue with this subject, is there a way to remove the "default url" (wp-content/uploads/) at the source of the code, not with a regex, and only for image with a alt=external ?
I've written an extension for MediaWiki that creates slideshow for images.
The problem is that while the image is used in the slideshow it doesn't show it is being used on the file page. How can I add page reference to File Usage section?
You need to add the image to the list of images in the ParserOutput object. You can get a ParserOutput object by calling $parser->getOutput(), and add an image to it with $parserOutput->addImage( $name ).
I'm using cakephp 2 and I'm trying to allow my users to upload an image which is then used as the background for their page.
I have the images uploading fine and saving to a (webroot)files/User/$userid/$bodybgimage. I've also got the name of the image in the database.
Trouble is I want because I don't know in advance what user id is going to be requesting their background image I can't put their background in the stylesheet, so I'm trying to get it added in the default layout. I've tried to add with jquery: (the image filename is in $bodybgimage)
<?php if(!$bodybgimage == '') {?>
$('body').css('background-image', 'url('<?php echo '../files/User/'.$userId.'/'.$bodybgimage; ?>')');
<?php }?>
But this seems to just remove everystyle I had for the body!
I also tried doing adding it straight to the body tag like so:
<body<?php if(!$bodybgimage == '') echo ' style="background-image:url(../files/User/'.$userId.'/'.$bodybgimage.')"';?>>
But again to no avail. Can anyone help me out. I know the image and all's there because if I put the background-image style in the stylesheet the image pops up ok. There must be a sensible way to do this that I'm missing. Plz help!
Please can you try to omit the "../" before the files as i assume that your images founded in a folder named files beside your script not ?
I have some thumbnail images with its larger version.I placed the thumbnail images in a page.Now for link I just gave a link
<img src="thumbnail1.jpg>
but for this I have to make different pages for showing larger one.I want to give a link to show them in a single page.means whenever I will click the thumbnail it will open the larger one in a page with the same url but with its name like
imagegallery.php?news=images/largerimage1/13.jpg
imagegallery.php?news=images/largerimage1/14.jpg
so how to do that?
Pretty basic stuff, I suggest you get to read some PHP tutorials on the internet to get some knowledge on one thing and another.
The ?news= part in your URL is a parameter that can be read by PHP. This type is known as $_GET. To get this part you would need $_GET['news'] so if we'd use your first link and place this inside a script: echo $_GET['news']; the page would say images/largerimages1/13.jpg.
In order to get the image loaded on your website we need some simple steps, I'm changing the news parameter into image, that suits better for your script since it ain't news items:
<?php
// Define the path (used to see if an image exists)
$path = 'your/absolute/path/to/public_html/'; # or wwwroot or www folder
// First check if the parameter is not empty
if($_GET['image'] != "") {
// Then check if the file is valid
if(file_exists($path . $_GET['image'])) {
// If an image exists then display image
echo '<img src="'. $_GET['image'] . '" />;
}
}
?>
Below this script you can put all your thumbnails the way you want. Ofcourse, also for these thumbnails there are some automated options. But I strongly suggest you get a good look at the script above and some beginner PHP tutorials so you completely understand the example given. This still isn't the best method, but it's kicking you in the right direction.
if your imagegallery.php is in root of your domain, you can just add slash as a first char to links like this:
<img src="thumbnail1.jpg>
else you will have to write some php function which it returns BaseUrl of your web. Then it should looks like this:
<img src="thumbnail1.jpg>
maybe you can something like this,
Techincally, there is no thumbnail image, just a stretch version of the regular image
I don't understand which part you don't know how to do:
- the link part?
it should look like
<img src="thumbnail1.jpg>
- or the PHP part (the file called imagegallery.php)?