Overwrite IpReflection - impresspages

I want to change Avatar, but I want to use ipReflection() too.
when I upload first image it works but when I change it stays the same, I tried to unbind then bind again same image but it doesn't work.
ipUnbindFile($image, 'UserModuleLogo', ipUser()->userId(), 'file/repository/UserFiles/');
ipBindFile($image, 'UserModuleLogo', ipUser()->userId(), 'file/repository/UserFiles/');

Binding the file is inserting its data to a database. There could be two issues, why changes aren't visible instantly:
Browser cache. You save a new file with the same file name and browser thinks nothing has changed.
Reflection cache. If filename is the same and options are the same, ImpressPages pulls image from the reflections without touching a new file.
To fix the first issue, always change filename or add random parameter and the end of the file, i.e. "image.jpg?1029231230".
To fix the second issue, always delete all reflection before replacing the file.

Related

Get a bit of code after image url in browser

I'm changing background image on hover.
The code for image url looks like this:
background-image: url('../assets/img/project1.png');
But when I look in the Chrome inspector it looks like this:
background-image: url(/img/project1.9fba20d0.png);
So when I try to change image need that code (9fba20d0) for it to work.
Why dose '9fba20d0' appear? How do I remove it or get it without hardcoding it?
I actually haven't used Vue.js, but I'm sure the random string appended to end of filename is for "cache busting" purposes.
Basically, the string changes each time you build your application so the next time you request index.html from the server it will reference the new filename (with a different random string at the end). If there was no string, the browser would look locally to find the file, which may be an outdated version, if you've made changes since last rebuild.
I'd try and understand how Vue.js is creating your production "assets", i.e. all the images and other static files and see if you have some options to change the default behavior, if need be. Might have to read the documentation pertaining to caching.
Hope that at least points you in the right direction!

Force Image control to re-download the image

I have an Image control on Page1.xaml that is pointing at a URL: http://www.example.com/blah.jpg
I navigate to Page2.xaml and upload a new image to that url using my WebAPI. I call Frame.GoBack() to navigate back to Page1.xaml.
The old image is still displayed in the Image control. How can I make sure that Image control re-downloads the image even though its at the same URL?
The only way I found was to append a query string to the end of the image. It's a bit of a hack and it can interfere with Save operations but it is effective.
Just to be clear, I set the property with the image url with a value like this:
"http://www.example.com/blah.jpg?id=" + Guid.NewGuid()
That triggers the RaisePropertyChanged event and the Image control is tricked into thinking the image changed.
Set the BitmapImage.CreateOptions property to IgnoreImageCache.
From MSDN:
The other possible value for CreateOptions is
BitmapCreateOptions.IgnoreImageCache. You should only use
BitmapCreateOptions.IgnoreImageCache in cases where you know that the
source image file as retrieved by URI has the potential to change over
time. Otherwise, setting CreateOptions to use
BitmapCreateOptions.IgnoreImageCache causes all newly retrieved image
sources to be decoded again, which can negatively impact performance.
...

Databinding uri source of imagebrush

In my application i am binding several properties to a custom user control, and everything works fine, except the images are not showing. For binding i have used the following codes:
Categories.Add(new Models.Category { Name = "Pizza", Count= 4, ImageUri = new Uri("Images/pizza.png", UriKind.Relative) });
I have also tried with different urikinds but the images are never showing.
what could go wrong? The images are in my solutions Images folder.
Use the ms-appx URI scheme:
ImageUri = new Uri("ms-appx:///Images/pizza.png");
Take care to really write ///.
Also make sure that the Build Action of the image file is set to Content, as pointed out in the other answer. Setting Copy to Output Directory does however not seem to be necessary.
Be sure you set the properties of the image so that it is available during runtime. Sometimes if employing Design Time data in Blend, you will see the images in Design Time, but then nothing during run time. The reason is that the images were never deployed with the rest of the solution. Be sure the Build Action on each image is set to Content and I usually set the Copy to Output Directory to Copy if Newer.

Save the modified Property file inside WAR deployed on server

We are trying to use Apache PropertiesConfiguration in our project using JSF and JBoss.
My property file is located inside a package say demo.prop by the name of Prop1.prop
Inside my WAR file the same is present under /WEB-INF/classes/demo/prop/Prop1.prop
Using
FacesContext.getCurrentInstance().getExternalContext().getResource("/WEB-INF/classes/demo/prop/Prop1.prop");
I am able to fetch the property file. So when I try to extract a string from the property file using
PropertiesConfiguration pc1=new PropertiesConfiguration(a);
String s1=(String)pc1.getProperty("User_Name");
I am able to get the proper string. Using set property method I am able to set the property also.
pc1.setProperty("User_Name", "hardcodedString");
But I am not able to save the FILE back to this location. No matter what I do it is not able to save the file using pc1.save.
Can anyone please try to tell me how can I save this file back to its original location so that the changes done in the property file remain as it is.
Modifying the WAR file is a bad idea (for example, some web servers may notice the file
modification an redeploy your app, there may be problems when the server explodes the war on deployment etc.)
I would suggest applying an alternative approach - some possibilities are:
Place the properties in a database table, so they can be easily modified
Use an external properties file for overriding your "Prop1.prop" file settings. You can pull this off for example as follows. Assume that the default property values are bundled in your WAR and the modified values are saved to some other path, which is defined using a system property - let say it's called CONFIG_LOCATION. Now after loading your properties from the bundle you read them also from this external "overrides.prop" file - this overrides your defaults from "Prop1.prop":
PropertiesConfiguration pc1=new PropertiesConfiguration(a);
try(FileReader propReader = new FileReader(System.getenv().get("CONFIG_FILES") +"/overrides.prop"){
pc1.load(propReader);
}
When you need to save changes, you do that to "overrides.prop" - this will save all
the properties, not only the changed ones, but that should have no negative effects.

Saving pdf in the background using html2pdf

Am tryng to automatically generate pdfs using html2pdf class. I got the following code which is working fine, only that someone has to save the pdf manually. However, Whenever a new product is added, I would like to automatically save the pdf to some folder without user intervention, and store this value in a database for future reference.
How do I go about saving the pdf 'silently' i.e. in the background without showing any popups or requiring the user to intervene?
Thanks in advance.
include('pdf_content.php');
$content = ob_get_clean();
// convert to PDF
require_once('html2pdf/html2pdf.class.php');
try
{
$html2pdf = new HTML2PDF('P', 'A4', 'en');
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->setDefaultFont('Arial');
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
//$html2pdf->Output($file_name.'_'.date("dmY").'.pdf');
$html2pdf->Output($product_id.'_'.$file_name.'_'.date("dmY").'.pdf');
You can try calling this script everytime a new product is added, although then you wouldn't really do it in the "background"...
For more information, please note the question "How can I run a PHP script in the background after a form is submitted?"
EDIT:
If you wish to save the file on the server instead of outputting it to the browser, you can use different parameters. See also the html2pdf-wiki. Be aware that you cannot save the file on the user's computer unnoticed!
$html2pdf->Output('directory/file_xxxx.pdf', 'F');